pricehubble 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -49
- data/CHANGELOG.md +4 -0
- data/Envfile +1 -0
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/lib/price_hubble/client/base.rb +0 -3
- data/lib/price_hubble/client/dossiers.rb +0 -14
- data/lib/price_hubble/client/utils/response.rb +0 -4
- data/lib/price_hubble/client/valuation.rb +0 -11
- data/lib/price_hubble/client.rb +1 -1
- data/lib/price_hubble/core_ext/hash.rb +1 -5
- data/lib/price_hubble/entity/authentication.rb +1 -1
- data/lib/price_hubble/entity/concern/associations.rb +1 -17
- data/lib/price_hubble/entity/concern/attributes.rb +2 -11
- data/lib/price_hubble/identity.rb +1 -1
- data/lib/price_hubble/utils/bangers.rb +1 -5
- data/lib/price_hubble/utils/decision.rb +2 -2
- data/lib/price_hubble/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 07e1e5efe0a100babe39f157a02b4068af1fad0ea51a08106660d37fa7b00fe8
|
|
4
|
+
data.tar.gz: 18b62eddc0faa937a242132836be220fe36e6519b2a7c71947fb7f13b9a82702
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ad7fad7e5697d103a3c574e8bf1cf23852861876fc5ac413b62c8a26f478a3f7830210ebe7ed0739eae68f6e5af68a2dcc1e67d71da0b18d34f6ae7bb1c87b7a
|
|
7
|
+
data.tar.gz: 0f844faeeaedb2ed00172e5accfaee4b244f0ccfdf7eea6e4300980ded042888717d93e9a0c3fc0e028e4b443189887c9981e039cb41bcae1dff85eab26248b8
|
data/.rubocop.yml
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
inherit_from:
|
|
2
|
+
- https://potpourri.hausgold.de/config/rubocop.yml
|
|
3
|
+
- https://potpourri.hausgold.de/config/rubocop-gem.yml
|
|
4
|
+
|
|
1
5
|
plugins:
|
|
2
6
|
- rubocop-rspec
|
|
3
7
|
- rubocop-rails
|
|
@@ -5,9 +9,6 @@ plugins:
|
|
|
5
9
|
Rails:
|
|
6
10
|
Enabled: true
|
|
7
11
|
|
|
8
|
-
Style/Documentation:
|
|
9
|
-
Enabled: true
|
|
10
|
-
|
|
11
12
|
AllCops:
|
|
12
13
|
NewCops: enable
|
|
13
14
|
SuggestExtensions: false
|
|
@@ -20,48 +21,17 @@ AllCops:
|
|
|
20
21
|
- build/**/*
|
|
21
22
|
- gemfiles/**/*
|
|
22
23
|
|
|
23
|
-
Metrics/BlockLength:
|
|
24
|
-
Exclude:
|
|
25
|
-
- Rakefile
|
|
26
|
-
- '*.gemspec'
|
|
27
|
-
- spec/**/*.rb
|
|
28
|
-
- '**/*.rake'
|
|
29
|
-
- doc/**/*.rb
|
|
30
|
-
# Concerns and middlewares contain by nature long blocks
|
|
31
|
-
- lib/price*hubble/entity/concern/**/*.rb
|
|
32
|
-
- lib/price*hubble/client/request/**/*.rb
|
|
33
|
-
- lib/price*hubble/client/response/**/*.rb
|
|
34
|
-
|
|
35
24
|
# Our examples use +pp+ a lot
|
|
36
25
|
Lint/Debugger:
|
|
37
26
|
Exclude:
|
|
38
27
|
- doc/examples/**/*.rb
|
|
39
28
|
|
|
40
|
-
# MFA is not yet enabled for our gems yet.
|
|
41
|
-
Gemspec/RequireMFA:
|
|
42
|
-
Enabled: false
|
|
43
|
-
|
|
44
|
-
# Document all the things.
|
|
45
|
-
Style/DocumentationMethod:
|
|
46
|
-
Enabled: true
|
|
47
|
-
RequireForNonPublicMethods: true
|
|
48
|
-
|
|
49
29
|
# It's a deliberate idiom in RSpec.
|
|
50
30
|
# See: https://github.com/bbatsov/rubocop/issues/4222
|
|
51
31
|
Lint/AmbiguousBlockAssociation:
|
|
52
32
|
Exclude:
|
|
53
33
|
- "spec/**/*"
|
|
54
34
|
|
|
55
|
-
# Because +expect_any_instance_of().to have_received()+ is not
|
|
56
|
-
# supported with the +with(hash_including)+ matchers
|
|
57
|
-
RSpec/MessageSpies:
|
|
58
|
-
EnforcedStyle: receive
|
|
59
|
-
|
|
60
|
-
# Because nesting makes sense here to group the feature tests
|
|
61
|
-
# more effective. This increases maintainability.
|
|
62
|
-
RSpec/NestedGroups:
|
|
63
|
-
Max: 4
|
|
64
|
-
|
|
65
35
|
# Disable regular Rails spec paths.
|
|
66
36
|
Rails/FilePath:
|
|
67
37
|
Enabled: false
|
|
@@ -75,26 +45,11 @@ Lint/ShadowingOuterLocalVariable:
|
|
|
75
45
|
Exclude:
|
|
76
46
|
- "doc/**/*"
|
|
77
47
|
|
|
78
|
-
# We stay at 80 characters per line.
|
|
79
|
-
# See: https://rubystyle.guide/#max-line-length
|
|
80
|
-
Layout/LineLength:
|
|
81
|
-
Max: 80
|
|
82
|
-
|
|
83
|
-
# We use memoized helpers all over the place to construct inputs and output
|
|
84
|
-
# which can be customized at nested contexts easily.
|
|
85
|
-
RSpec/MultipleMemoizedHelpers:
|
|
86
|
-
Enabled: false
|
|
87
|
-
|
|
88
48
|
# That are false-positives because we implement similar working
|
|
89
49
|
# helpers for associations like +.has_one+.
|
|
90
50
|
Rails/ReflectionClassName:
|
|
91
51
|
Enabled: false
|
|
92
52
|
|
|
93
|
-
# A very nice feature, but it does not work for non-method code parts atow.
|
|
94
|
-
# So just disabling it for now.
|
|
95
|
-
Style/DocumentDynamicEvalDefinition:
|
|
96
|
-
Enabled: false
|
|
97
|
-
|
|
98
53
|
# For our examples it's fine to use +pp+ and +puts+,
|
|
99
54
|
# as they are living examples.
|
|
100
55
|
Rails/Output:
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
* TODO: Replace this bullet point with an actual description of a change.
|
|
4
4
|
|
|
5
|
+
### 2.2.0 (19 December 2025)
|
|
6
|
+
|
|
7
|
+
* Migrated to a shared Rubocop configuration for HAUSGOLD gems ([#21](https://github.com/hausgold/pricehubble/pull/21))
|
|
8
|
+
|
|
5
9
|
### 2.1.0 (23 October 2025)
|
|
6
10
|
|
|
7
11
|
* Added support for Rails 8.1 ([#19](https://github.com/hausgold/pricehubble/pull/19))
|
data/Envfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -123,7 +123,7 @@ PriceHubble.identity.expires_at
|
|
|
123
123
|
|
|
124
124
|
The pricehubble gem allows you to decide how to react on errors on a
|
|
125
125
|
per-request basis. (except the transparent authentication) All request
|
|
126
|
-
performing methods are
|
|
126
|
+
performing methods are shipped in a bang and non-bang variant.
|
|
127
127
|
|
|
128
128
|
The bang variants (eg. `PriceHubble::ValuationRequest#perform!`, mind
|
|
129
129
|
the exclamation mark at the end) will raise an child instance of the
|
|
@@ -133,7 +133,7 @@ occur. This comes in handy on asynchronous jobs which are retried on
|
|
|
133
133
|
exceptions.
|
|
134
134
|
|
|
135
135
|
The non-bang variants (eg. `PriceHubble::ValuationRequest#perform`,
|
|
136
|
-
without the exclamation mark)
|
|
136
|
+
without the exclamation mark) won't raise and just return empty results
|
|
137
137
|
(eg. `false` or `[]`). This might me comfortable in complex control
|
|
138
138
|
flows or when you do not care if one out of 100 times the data is
|
|
139
139
|
missing. But watch out for bad/invalid requests you might mask with
|
|
@@ -23,8 +23,6 @@ module PriceHubble
|
|
|
23
23
|
# end
|
|
24
24
|
#
|
|
25
25
|
# @param con [Faraday::Connection] the connection object
|
|
26
|
-
#
|
|
27
|
-
# rubocop:disable Metrics/MethodLength -- because of the middleware list
|
|
28
26
|
def configure(con)
|
|
29
27
|
con.use :instrumentation
|
|
30
28
|
|
|
@@ -44,7 +42,6 @@ module PriceHubble
|
|
|
44
42
|
|
|
45
43
|
con.adapter Faraday.default_adapter
|
|
46
44
|
end
|
|
47
|
-
# rubocop:enable Metrics/MethodLength
|
|
48
45
|
|
|
49
46
|
# Create a new Faraday connection on the first shot, and pass the cached
|
|
50
47
|
# connection object on subsequent calls.
|
|
@@ -10,9 +10,6 @@ module PriceHubble
|
|
|
10
10
|
# @param args [Hash{Symbol => Mixed}] additional arguments
|
|
11
11
|
# @return [PriceHubble::Dossier, nil] the PriceHubble dossier,
|
|
12
12
|
# or +nil+ on error
|
|
13
|
-
#
|
|
14
|
-
# rubocop:disable Metrics/MethodLength -- because thats the bare minimum
|
|
15
|
-
# handling is quite complex
|
|
16
13
|
def create_dossier(entity, **args)
|
|
17
14
|
res = connection.post do |req|
|
|
18
15
|
req.path = '/api/v1/dossiers'
|
|
@@ -26,7 +23,6 @@ module PriceHubble
|
|
|
26
23
|
successful?(res)
|
|
27
24
|
end
|
|
28
25
|
end
|
|
29
|
-
# rubocop:enable Metrics/MethodLength
|
|
30
26
|
|
|
31
27
|
# Generates a permalink for the specified dossier which will expire after
|
|
32
28
|
# the set number of days.
|
|
@@ -35,10 +31,6 @@ module PriceHubble
|
|
|
35
31
|
# @param ttl [ActiveSupport::Duration] the time to live for the new link
|
|
36
32
|
# @param locale [String] the user frontend locale
|
|
37
33
|
# @param args [Hash{Symbol => Mixed}] additional arguments
|
|
38
|
-
#
|
|
39
|
-
# rubocop:disable Metrics/MethodLength -- because thats the bare minimum
|
|
40
|
-
# rubocop:disable Metrics/AbcSize -- because the decission handling is
|
|
41
|
-
# quite complex
|
|
42
34
|
def share_dossier(entity, ttl:, locale:, **args)
|
|
43
35
|
res = connection.post do |req|
|
|
44
36
|
req.path = '/api/v1/dossiers/links'
|
|
@@ -57,16 +49,11 @@ module PriceHubble
|
|
|
57
49
|
successful?(res)
|
|
58
50
|
end
|
|
59
51
|
end
|
|
60
|
-
# rubocop:enable Metrics/MethodLength
|
|
61
|
-
# rubocop:enable Metrics/AbcSize
|
|
62
52
|
|
|
63
53
|
# Delete a dossier entity.
|
|
64
54
|
#
|
|
65
55
|
# @param entity [PriceHubble::Dossier] the entity to delete
|
|
66
56
|
# @param args [Hash{Symbol => Mixed}] additional arguments
|
|
67
|
-
#
|
|
68
|
-
# rubocop:disable Metrics/MethodLength -- because thats the bare
|
|
69
|
-
# minimumbecause the decission handling is quite complex
|
|
70
57
|
def delete_dossier(entity, **args)
|
|
71
58
|
res = connection.delete do |req|
|
|
72
59
|
req.path = "/api/v1/dossiers/#{entity.id}"
|
|
@@ -82,7 +69,6 @@ module PriceHubble
|
|
|
82
69
|
end
|
|
83
70
|
end
|
|
84
71
|
|
|
85
|
-
# rubocop:enable Metrics/MethodLength
|
|
86
72
|
# Update a dossier entity.
|
|
87
73
|
#
|
|
88
74
|
# TODO: Implement this.
|
|
@@ -4,9 +4,6 @@ module PriceHubble
|
|
|
4
4
|
module Client
|
|
5
5
|
module Utils
|
|
6
6
|
# Some helpers to work with responses in a general way.
|
|
7
|
-
#
|
|
8
|
-
# rubocop:disable Metrics/BlockLength -- because of
|
|
9
|
-
# ActiveSupport::Concern
|
|
10
7
|
module Response
|
|
11
8
|
extend ActiveSupport::Concern
|
|
12
9
|
|
|
@@ -82,7 +79,6 @@ module PriceHubble
|
|
|
82
79
|
end
|
|
83
80
|
end
|
|
84
81
|
end
|
|
85
|
-
# rubocop:enable Metrics/BlockLength
|
|
86
82
|
end
|
|
87
83
|
end
|
|
88
84
|
end
|
|
@@ -10,9 +10,6 @@ module PriceHubble
|
|
|
10
10
|
# @param args [Hash{Symbol => Mixed}] the authentication credentials
|
|
11
11
|
# @return [Array<PriceHubble::Valuation>, nil] the valuation results,
|
|
12
12
|
# or +nil+ on error
|
|
13
|
-
#
|
|
14
|
-
# rubocop:disable Metrics/MethodLength -- because of the request handling
|
|
15
|
-
# rubocop:disable Metrics/AbcSize -- ditto
|
|
16
13
|
def property_value(request, **args)
|
|
17
14
|
data = request.attributes(sanitize: true)
|
|
18
15
|
res = connection.post do |req|
|
|
@@ -27,8 +24,6 @@ module PriceHubble
|
|
|
27
24
|
successful?(res)
|
|
28
25
|
end
|
|
29
26
|
end
|
|
30
|
-
# rubocop:enable Metrics/MethodLength
|
|
31
|
-
# rubocop:enable Metrics/AbcSize
|
|
32
27
|
|
|
33
28
|
# Map and assign the valuation response to our local
|
|
34
29
|
# +PriceHubble::Valuation+ representation. While taking care of the
|
|
@@ -41,10 +36,6 @@ module PriceHubble
|
|
|
41
36
|
# valuations data
|
|
42
37
|
# @param request [PriceHubble::ValuationRequest] the original request
|
|
43
38
|
# @return [Proc] the valuation mapping code
|
|
44
|
-
#
|
|
45
|
-
# rubocop:disable Metrics/MethodLength -- because of the request to
|
|
46
|
-
# response mapping
|
|
47
|
-
# rubocop:disable Metrics/AbcSize -- ditto
|
|
48
39
|
def assign_valuations(data, request)
|
|
49
40
|
lambda do
|
|
50
41
|
# valuations[i][j] contains the valuation for property i on date j
|
|
@@ -62,8 +53,6 @@ module PriceHubble
|
|
|
62
53
|
end.flatten
|
|
63
54
|
end
|
|
64
55
|
end
|
|
65
|
-
# rubocop:enable Metrics/MethodLength
|
|
66
|
-
# rubocop:enable Metrics/AbcSize
|
|
67
56
|
|
|
68
57
|
# Generate bang method variants
|
|
69
58
|
bangers :property_value
|
data/lib/price_hubble/client.rb
CHANGED
|
@@ -7,7 +7,7 @@ module PriceHubble
|
|
|
7
7
|
|
|
8
8
|
class_methods do
|
|
9
9
|
# Get a low level client for the requested application. This returns an
|
|
10
|
-
# already
|
|
10
|
+
# already instantiated client object, ready to use.
|
|
11
11
|
#
|
|
12
12
|
# @param name [Symbol, String] the client name
|
|
13
13
|
# @return [PriceHubble::Client::Base] a compatible client instance
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# All our Ruby core extensions for the +Hash+ class.
|
|
4
4
|
class Hash
|
|
5
5
|
# Perform the regular +Hash#compact+ method on the object but takes care of
|
|
6
|
-
# deeply nested
|
|
6
|
+
# deeply nested hashes.
|
|
7
7
|
#
|
|
8
8
|
# @return [Hash]
|
|
9
9
|
def deep_compact
|
|
@@ -32,9 +32,6 @@ class Hash
|
|
|
32
32
|
#
|
|
33
33
|
# @param object [Mixed] the object to compact
|
|
34
34
|
# @return [Mixed] the compacted object
|
|
35
|
-
#
|
|
36
|
-
# rubocop:disable Metrics/MethodLength -- because of the extra empty hash
|
|
37
|
-
# compaction logic
|
|
38
35
|
def deep_compact_in_object(object)
|
|
39
36
|
case object
|
|
40
37
|
when Hash
|
|
@@ -48,5 +45,4 @@ class Hash
|
|
|
48
45
|
object
|
|
49
46
|
end
|
|
50
47
|
end
|
|
51
|
-
# rubocop:enable Metrics/MethodLength
|
|
52
48
|
end
|
|
@@ -6,7 +6,7 @@ module PriceHubble
|
|
|
6
6
|
#
|
|
7
7
|
# @see https://docs.pricehubble.com/#introduction-authentication
|
|
8
8
|
class Authentication < BaseEntity
|
|
9
|
-
# The expiration leeway to
|
|
9
|
+
# The expiration leeway to subtract to guarantee
|
|
10
10
|
# acceptance on remote application calls
|
|
11
11
|
EXPIRATION_LEEWAY = 5.minutes
|
|
12
12
|
|
|
@@ -8,7 +8,7 @@ module PriceHubble
|
|
|
8
8
|
extend ActiveSupport::Concern
|
|
9
9
|
|
|
10
10
|
included do
|
|
11
|
-
# Collect all the
|
|
11
|
+
# Collect all the registered association configurations
|
|
12
12
|
class_attribute :associations
|
|
13
13
|
|
|
14
14
|
private
|
|
@@ -37,9 +37,6 @@ module PriceHubble
|
|
|
37
37
|
# @param hash [Hash{Symbol => Mixed}] all the data as hash
|
|
38
38
|
# @return [Array<RecursiveOpenStruct, Hash{Symbol => Mixed}>] the
|
|
39
39
|
# left over data
|
|
40
|
-
#
|
|
41
|
-
# rubocop:disable Metrics/AbcSize -- because of the complex logic
|
|
42
|
-
# rubocop:disable Metrics/MethodLength -- because of the complex logic
|
|
43
40
|
def map_has_one_association(attribute, opts, struct, hash)
|
|
44
41
|
# Early exit when the source key is missing on the given data
|
|
45
42
|
key = opts[:from]
|
|
@@ -62,8 +59,6 @@ module PriceHubble
|
|
|
62
59
|
# Pass back the new data
|
|
63
60
|
[struct, hash]
|
|
64
61
|
end
|
|
65
|
-
# rubocop:enable Metrics/AbcSize
|
|
66
|
-
# rubocop:enable Metrics/MethodLength
|
|
67
62
|
|
|
68
63
|
# Map an simple has_many association to the resulting entity attribute.
|
|
69
64
|
# The source key is stripped off according to the association
|
|
@@ -76,13 +71,6 @@ module PriceHubble
|
|
|
76
71
|
# @param hash [Hash{Symbol => Mixed}] all the data as hash
|
|
77
72
|
# @return [Array<RecursiveOpenStruct, Hash{Symbol => Mixed}>] the
|
|
78
73
|
# left over data
|
|
79
|
-
#
|
|
80
|
-
# rubocop:disable Metrics/AbcSize -- because of the complex logic
|
|
81
|
-
# rubocop:disable Metrics/CyclomaticComplexity -- because of the
|
|
82
|
-
# complex logic
|
|
83
|
-
# rubocop:disable Metrics/PerceivedComplexity -- because of the complex
|
|
84
|
-
# logic
|
|
85
|
-
# rubocop:disable Metrics/MethodLength -- because of the complex logic
|
|
86
74
|
def map_has_many_association(attribute, opts, struct, hash)
|
|
87
75
|
# Early exit when the source key is missing on the given data
|
|
88
76
|
key = opts[:from]
|
|
@@ -114,10 +102,6 @@ module PriceHubble
|
|
|
114
102
|
# Pass back the new data
|
|
115
103
|
[struct, hash]
|
|
116
104
|
end
|
|
117
|
-
# rubocop:enable Metrics/AbcSize
|
|
118
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
|
119
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
|
120
|
-
# rubocop:enable Metrics/MethodLength
|
|
121
105
|
end
|
|
122
106
|
|
|
123
107
|
class_methods do
|
|
@@ -5,7 +5,6 @@ module PriceHubble
|
|
|
5
5
|
# An ActiveRecord-like attribute management feature, with the exception
|
|
6
6
|
# that the attributes are not generated through a schema file, but are
|
|
7
7
|
# defined inline the entity class.
|
|
8
|
-
#
|
|
9
8
|
module Attributes
|
|
10
9
|
extend ActiveSupport::Concern
|
|
11
10
|
|
|
@@ -16,7 +15,7 @@ module PriceHubble
|
|
|
16
15
|
include Attributes::Range
|
|
17
16
|
include Attributes::StringInquirer
|
|
18
17
|
|
|
19
|
-
# Collect all
|
|
18
|
+
# Collect all registered attribute names as symbols
|
|
20
19
|
class_attribute :attribute_names
|
|
21
20
|
|
|
22
21
|
# Export all attributes as data hash, as requested by the ActiveModel
|
|
@@ -24,9 +23,6 @@ module PriceHubble
|
|
|
24
23
|
#
|
|
25
24
|
# @param sanitize [Boolean] whenever to sanitize the data for transport
|
|
26
25
|
# @return [Hash{String => Mixed}] the attribute data
|
|
27
|
-
#
|
|
28
|
-
# rubocop:disable Metrics/MethodLength -- because of the key/value
|
|
29
|
-
# sanitization handling
|
|
30
26
|
def attributes(sanitize: false)
|
|
31
27
|
attribute_names.each_with_object({}) do |key, memo|
|
|
32
28
|
reader = key
|
|
@@ -44,7 +40,6 @@ module PriceHubble
|
|
|
44
40
|
end
|
|
45
41
|
end
|
|
46
42
|
|
|
47
|
-
# rubocop:enable Metrics/MethodLength
|
|
48
43
|
# A wrapper for the +ActiveModel#assign_attributes+ method with support
|
|
49
44
|
# for unmapped attributes. These attributes are put into the
|
|
50
45
|
# +_unmapped+ struct and all the known attributes are assigned like
|
|
@@ -73,9 +68,6 @@ module PriceHubble
|
|
|
73
68
|
# @param obj [Mixed] the object to resolve its attributes
|
|
74
69
|
# @param sanitize [Boolean] whenever to sanitize the data for transport
|
|
75
70
|
# @return [Mixed] the attribute(s) data
|
|
76
|
-
#
|
|
77
|
-
# rubocop:disable Metrics/MethodLength -- because thats the pure
|
|
78
|
-
# minimum
|
|
79
71
|
def resolve_attributes(obj, sanitize: false)
|
|
80
72
|
if obj.respond_to? :attributes
|
|
81
73
|
obj = if obj.method(:attributes).arity == 1
|
|
@@ -93,7 +85,6 @@ module PriceHubble
|
|
|
93
85
|
|
|
94
86
|
obj
|
|
95
87
|
end
|
|
96
|
-
# rubocop:enable Metrics/MethodLength
|
|
97
88
|
|
|
98
89
|
# Explicitly convert the given struct to an +RecursiveOpenStruct+ and a
|
|
99
90
|
# deep symbolized key copy for further usage.
|
|
@@ -122,7 +113,7 @@ module PriceHubble
|
|
|
122
113
|
# @param hash [Hash{Symbol => Mixed}] all the data as hash
|
|
123
114
|
# @return [Hash{Symbol => Mixed}] the known attributes
|
|
124
115
|
def initialize_attributes(struct, hash)
|
|
125
|
-
#
|
|
116
|
+
# Subtract known keys, to move them to the +_unmapped+ variable
|
|
126
117
|
attribute_names.each { |key| struct.delete_field(key) }
|
|
127
118
|
# Merge the previous unmapped struct and the given data
|
|
128
119
|
self._unmapped =
|
|
@@ -14,13 +14,10 @@ module PriceHubble
|
|
|
14
14
|
# @param methods [Array<Symbol>] the source method names
|
|
15
15
|
# @raise [NoMethodError] when a source method is not defined
|
|
16
16
|
# @raise [ArgumentError] when a source method does not accept arguments
|
|
17
|
-
#
|
|
18
|
-
# rubocop:disable Metrics/MethodLength -- because the method template
|
|
19
|
-
# is better inlined
|
|
20
17
|
def bangers(*methods)
|
|
21
18
|
methods.each do |meth|
|
|
22
19
|
raise NoMethodError, "#{self}##{meth} does not exit" \
|
|
23
|
-
unless
|
|
20
|
+
unless method_defined?(meth, false)
|
|
24
21
|
|
|
25
22
|
if instance_method(meth).arity.zero?
|
|
26
23
|
raise ArgumentError,
|
|
@@ -34,7 +31,6 @@ module PriceHubble
|
|
|
34
31
|
RUBY
|
|
35
32
|
end
|
|
36
33
|
end
|
|
37
|
-
# rubocop:enable Metrics/MethodLength
|
|
38
34
|
end
|
|
39
35
|
end
|
|
40
36
|
end
|
|
@@ -25,7 +25,7 @@ module PriceHubble
|
|
|
25
25
|
# switch statement. It contains three decision result paths, the happy
|
|
26
26
|
# case (good), an error case for regular issues (fail) and a error case
|
|
27
27
|
# for fatal issues (bang). You can configure the decision which error
|
|
28
|
-
#
|
|
28
|
+
# behaviour you prefer by setting the +bang+ argument to true or
|
|
29
29
|
# false.
|
|
30
30
|
#
|
|
31
31
|
# @param bang [Boolean] whenever to bang or not
|
|
@@ -73,7 +73,7 @@ module PriceHubble
|
|
|
73
73
|
@good_proc = block
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
# Returns the
|
|
76
|
+
# Returns the preferred error method block, based on the +on_error+
|
|
77
77
|
# setting.
|
|
78
78
|
#
|
|
79
79
|
# @return [Proc] the error block we should use
|
data/lib/price_hubble/version.rb
CHANGED