yinum 1.7.2 → 1.7.3
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/Gemfile.lock +1 -1
- data/lib/enum/helpers/enum_attribute.rb +2 -2
- data/lib/enum/version.rb +1 -1
- data/spec/lib/enum/helpers/enum_attribute_spec.rb +19 -1
- 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: 2c63699e6b2f39a6fafb079fa52596f79bdbf58e
|
4
|
+
data.tar.gz: 3693827578af653b27489c630592b995829f7e3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40532b803d520af6ad8a9543ad15c76089a1ad32cfa627cdf9d143a3f6d44e59c2d3b12808d9068cea538d064c386c2ef1d510048193afe1d5bac3f13ca55073
|
7
|
+
data.tar.gz: 561be7c18be076fd5ca2500b4fc76e57604ac36827d255afe1a7cbda267d0a8571a2df1fd58ed55031e6c76f18a0620905319e92bde1736cb798c5913376aed7
|
data/CHANGELOG.md
CHANGED
@@ -12,3 +12,7 @@
|
|
12
12
|
* Added `Object#enum_value?` to fix `attr_enum`'s writer, `BasicObject` does
|
13
13
|
not have `respond_to?`.
|
14
14
|
* Fix specs that didn't catch above bug.
|
15
|
+
|
16
|
+
**1.7.3**
|
17
|
+
* `attr_enum`'s writer to accept empty string.
|
18
|
+
* `attr_enum`'s qualifier option to use the object's `#send` rather than `#[]`.
|
data/Gemfile.lock
CHANGED
@@ -24,7 +24,7 @@ module Enum::Helpers::EnumAttribute
|
|
24
24
|
define_method("#{attr}=") do |v|
|
25
25
|
if v.enum_value?
|
26
26
|
super(v.value)
|
27
|
-
elsif v.nil?
|
27
|
+
elsif v.nil? or v == "" # might be received from forms
|
28
28
|
super(v)
|
29
29
|
else
|
30
30
|
super(e[v].value)
|
@@ -34,7 +34,7 @@ module Enum::Helpers::EnumAttribute
|
|
34
34
|
if options[:qualifier]
|
35
35
|
# generating scopes and questioning methods
|
36
36
|
e.by_name.each do |n, ev|
|
37
|
-
define_method("#{n}?") {
|
37
|
+
define_method("#{n}?") { send(attr) == ev }
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
data/lib/enum/version.rb
CHANGED
@@ -54,12 +54,24 @@ def enum_attribute_specs
|
|
54
54
|
@record[:color].should_not be_enum_value
|
55
55
|
end
|
56
56
|
|
57
|
-
specify "
|
57
|
+
specify "empty string" do
|
58
|
+
@record.color = ""
|
59
|
+
@record[:color].should == ""
|
60
|
+
@record[:color].should_not be_enum_value
|
61
|
+
end
|
62
|
+
|
63
|
+
specify "symbol name" do
|
58
64
|
@record.color = :red
|
59
65
|
@record[:color].should == 1
|
60
66
|
@record[:color].should_not be_enum_value
|
61
67
|
end
|
62
68
|
|
69
|
+
specify "string name" do
|
70
|
+
@record.color = 'red'
|
71
|
+
@record[:color].should == 1
|
72
|
+
@record[:color].should_not be_enum_value
|
73
|
+
end
|
74
|
+
|
63
75
|
specify "value" do
|
64
76
|
@record.color = 2
|
65
77
|
@record[:color].should == 2
|
@@ -89,6 +101,12 @@ def enum_attribute_specs
|
|
89
101
|
@record.color.should == 3
|
90
102
|
@record.color.should be_enum_value
|
91
103
|
end
|
104
|
+
|
105
|
+
specify "invalid empty string" do
|
106
|
+
@record[:color] = ""
|
107
|
+
@record.color.should == ""
|
108
|
+
@record.color.should be_enum_value
|
109
|
+
end
|
92
110
|
end # context "getter"
|
93
111
|
end # context "attribute"
|
94
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yinum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oded Niv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|