finer_struct 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/finer_struct/named.rb +2 -1
- data/lib/finer_struct/version.rb +1 -1
- data/spec/finer_struct/shared_examples.rb +4 -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: efc9874761281c4def8fcadbb25882b1c80946d0
|
4
|
+
data.tar.gz: f2b19060bc14eb3af7c2b8d021c52f061245d141
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8d08f594eccc29b4ecd5a12caa9fc2c4501ca25ea2360988e059053617e554f3cc8650796b7c7ef596bab2f78ea2e6c28b5d51f08e9bdfdfa53e40678beaeb2
|
7
|
+
data.tar.gz: b7aaae5aae267c3499dba6a47e21a92794d29957db92bd47382dc435775d778bdcc5b55e5fec538387fd173e32c677fa111f6928089359296d935858b1bfbd5e
|
data/lib/finer_struct/named.rb
CHANGED
@@ -8,7 +8,8 @@ module FinerStruct
|
|
8
8
|
raise(ArgumentError, "unknown attributes: #{unknown_attributes.join(', ')}")
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
nil_attributes = Hash[attribute_names.zip()]
|
12
|
+
super(nil_attributes.merge!(attributes))
|
12
13
|
end
|
13
14
|
|
14
15
|
def self.build_class(superclass, attribute_names)
|
data/lib/finer_struct/version.rb
CHANGED
@@ -26,4 +26,8 @@ shared_examples "a named struct" do
|
|
26
26
|
it "complains if you set attributes that the struct doesn't have" do
|
27
27
|
expect { klass.new(c: 3, d: 4) }.to raise_error(ArgumentError, "unknown attributes: c, d")
|
28
28
|
end
|
29
|
+
|
30
|
+
it "returns nil for attributes that aren't explicitly set" do
|
31
|
+
expect(klass.new(a: 1).b).to be_nil
|
32
|
+
end
|
29
33
|
end
|