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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d927809a2d8cd1a5da0e4e910942027d230dfb45
4
- data.tar.gz: 80988c71e715df538d82b902846ca660e5f5a4fb
3
+ metadata.gz: a03ce9220bfff01deb8bd149a84375a38873bc7f
4
+ data.tar.gz: d4b97c8e31eaaa0e12a44fc872f7882325ed94d7
5
5
  SHA512:
6
- metadata.gz: 8d9bd920c1a3227cd592dab70c0035124322bc0a358ed535b8aa5e42c6a8fb26bdcde0c85c8ef92a81131179e0b9fafbb928ccff2ab454164bc549cec36bd745
7
- data.tar.gz: 96ff27fb9e371d898f3056159a644cb3828ad2e10bc3c83273fb38ab8441661e78f46bf4f2960b59f0af09affaa39cb8033f5a75b64efbc74476705268a73735
6
+ metadata.gz: e8a01917e46705498fafd11c0df34424cc0cf35c69d9376c091f7ceb58b08553ee528e1ccf9fdc2fbf2961352745ecfa9ec030c1b9dac513b432cb6231926a32
7
+ data.tar.gz: 449c6e92127085a5efb2b8021a6335de05bce8a75008ec51ab523956eb057ce2cdd2d6384206ede335ec368f93a6ed8e3c130cfdbbfcbeb9f76aef609f7bd299
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ # 6.2.0
4
+
5
+ * Another bugfix when passing hash values to positional arguments.
6
+
3
7
  # 6.1.0
4
8
 
5
9
  * Bugfix when passing hash values to positional arguments.
@@ -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.select { |name| name.is_a?(Hash) }.inject(:merge) || {}
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)
@@ -1,3 +1,3 @@
1
1
  module AttrExtras
2
- VERSION = "6.1.0"
2
+ VERSION = "6.2.0"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.0
4
+ version: 6.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh