restricted_struct 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4990efc33886647ac9d035269794891b1f4a5e7b
4
- data.tar.gz: b11ebf6330ea5d3fced870c3c577cd01d61d650b
3
+ metadata.gz: c57385ce2f76e0faf9456f35dcc0cda0f794233a
4
+ data.tar.gz: f0cadea78f17cda8845217aabba5abb35edd37b2
5
5
  SHA512:
6
- metadata.gz: f2e2200102af51fcd8947504095a5c6b596d23f9b30e66913e2c751f15757d84f7858b53693bb55c29ce044193b42cf2d80174674b3c731acc5e2237bb906c79
7
- data.tar.gz: e9a3d4fa4b02bd90a25170ad38c646c1b47d4838bdcb60644dbfebaa528cb73c0143332ae26128743ac6e664f4c6eeba129cf05c96c01164e6615316a4b7e6c7
6
+ metadata.gz: 8816a49848678a035fee98d84d23d3c701289cfd6db29d4a00d383e72199a1db1d55266ea71a370384bf95e8f6603aeaa15a41c8ddea0fa5916abaa0363d7eb3
7
+ data.tar.gz: 5b6b920beeaff2f83add12ac4e054fb8bca406fb2f4ae3ecb0c6e292f42a940f8c06e24e33f281923b537e415d3a1279c966bf2129b54c9c27bde07ecedcc8c2
@@ -45,7 +45,7 @@ class RestrictedStruct < Struct
45
45
  members.each_with_index do |name, index|
46
46
  # 1.8 compatibility
47
47
  key = name.to_sym
48
- values[index] ||= self.class.defaults[key]
48
+ values[index] = self.class.defaults[key] if nil == values[index]
49
49
  values[index] = keyword_args[key] if keyword_args.has_key?(key)
50
50
  end
51
51
  super(*values)
@@ -1 +1 @@
1
- RestrictedStruct::VERSION = "0.2.0"
1
+ RestrictedStruct::VERSION = "0.2.1"
@@ -23,6 +23,27 @@ RSpec.describe RestrictedStruct do
23
23
  end
24
24
  end
25
25
 
26
+ describe "deals with falsy arguments properly" do
27
+ let(:point) { RestrictedStruct.new(:private, :a, :b) }
28
+ subject { point[*args].values }
29
+
30
+ context "when argument is nil" do
31
+ let(:args) { [nil, nil] }
32
+
33
+ it "holds nil inside" do
34
+ is_expected.to eq([nil, nil])
35
+ end
36
+ end
37
+
38
+ context "when argument is false" do
39
+ let(:args) { [nil, false] }
40
+
41
+ it "holds false inside" do
42
+ is_expected.to eq([nil, false])
43
+ end
44
+ end
45
+ end
46
+
26
47
  describe "keyword arguments" do
27
48
  let(:rectangle) { RestrictedStruct.new(:protected, :x1, :y1, :x2, :y2, :color => :white) }
28
49
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restricted_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Fedorov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-30 00:00:00.000000000 Z
12
+ date: 2015-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler