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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2d50d2731f00aceba47464bf8cbe73d4a91a01f1
4
- data.tar.gz: 26bc3ed9869a9c39065ae635627232e5a1aadb19
3
+ metadata.gz: 2c63699e6b2f39a6fafb079fa52596f79bdbf58e
4
+ data.tar.gz: 3693827578af653b27489c630592b995829f7e3e
5
5
  SHA512:
6
- metadata.gz: 857019820b29df357921fe69c2cc006d77af3969f2f9deabee50c9347bc9263680e8fac84cbda800c04a647a8feb779d9807343bafc2f4bd1406ff875fcd78d4
7
- data.tar.gz: ba7a24c3960486e6d7766da19fa4434acd8005792db599bb883afa843372b96cee4205e07c8ac6b466a1f03a81d3832b90274508a398f256d2071787a69139b7
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yinum (1.7.1)
4
+ yinum (1.7.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -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}?") { self[attr] == ev }
37
+ define_method("#{n}?") { send(attr) == ev }
38
38
  end
39
39
  end
40
40
 
data/lib/enum/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Enum
2
- VERSION = '1.7.2'
2
+ VERSION = '1.7.3'
3
3
  end
@@ -54,12 +54,24 @@ def enum_attribute_specs
54
54
  @record[:color].should_not be_enum_value
55
55
  end
56
56
 
57
- specify "name" do
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.2
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-18 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec