restricted_struct 0.2.0 → 0.2.1
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/lib/restricted_struct/definition.rb +1 -1
- data/lib/restricted_struct/version.rb +1 -1
- data/spec/restricted_struct_spec.rb +21 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c57385ce2f76e0faf9456f35dcc0cda0f794233a
|
4
|
+
data.tar.gz: f0cadea78f17cda8845217aabba5abb35edd37b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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]
|
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.
|
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.
|
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-
|
12
|
+
date: 2015-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|