attr_extras 6.1.0 → 6.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/CHANGELOG.md +4 -0
- data/lib/attr_extras/attr_initialize.rb +1 -1
- data/lib/attr_extras/version.rb +1 -1
- data/spec/attr_extras/attr_initialize_spec.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a03ce9220bfff01deb8bd149a84375a38873bc7f
|
4
|
+
data.tar.gz: d4b97c8e31eaaa0e12a44fc872f7882325ed94d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8a01917e46705498fafd11c0df34424cc0cf35c69d9376c091f7ceb58b08553ee528e1ccf9fdc2fbf2961352745ecfa9ec030c1b9dac513b432cb6231926a32
|
7
|
+
data.tar.gz: 449c6e92127085a5efb2b8021a6335de05bce8a75008ec51ab523956eb057ce2cdd2d6384206ede335ec368f93a6ed8e3c130cfdbbfcbeb9f76aef609f7bd299
|
data/CHANGELOG.md
CHANGED
@@ -19,7 +19,7 @@ class AttrExtras::AttrInitialize
|
|
19
19
|
validate_args = method(:validate_args)
|
20
20
|
|
21
21
|
klass.send(:define_method, :initialize) do |*values|
|
22
|
-
hash_values = values.
|
22
|
+
hash_values = (values[(klass_params.positional_args.length)..-1] || []).inject(:merge) || {}
|
23
23
|
|
24
24
|
validate_arity.call(values.length, self.class)
|
25
25
|
validate_args.call(values, klass_params)
|
data/lib/attr_extras/version.rb
CHANGED
@@ -103,6 +103,18 @@ describe Object, ".attr_initialize" do
|
|
103
103
|
exception.message.must_include "[:bar]"
|
104
104
|
end
|
105
105
|
|
106
|
+
# Regression.
|
107
|
+
it "doesn't store hash values to positional arguments as ivars" do
|
108
|
+
klass = Class.new do
|
109
|
+
attr_initialize :foo
|
110
|
+
attr_reader :foo
|
111
|
+
end
|
112
|
+
|
113
|
+
# Should not raise.
|
114
|
+
example = klass.new({ "invalid.ivar.name" => 123 })
|
115
|
+
example.foo.must_equal({ "invalid.ivar.name" => 123 })
|
116
|
+
end
|
117
|
+
|
106
118
|
it "accepts a block for initialization" do
|
107
119
|
klass = Class.new do
|
108
120
|
attr_initialize :value do
|