mschuerig-easy_enums 0.0.1 → 0.0.2
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.
- data/History.txt +4 -0
- data/README.rdoc +3 -3
- data/lib/easy_enums.rb +4 -4
- data/test/test_easy_enums.rb +7 -7
- metadata +1 -1
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -17,9 +17,9 @@ Simplistic enumerations for ActiveRecord.
|
|
17
17
|
|
18
18
|
class Color < ActiveRecord::Base
|
19
19
|
enumerates do |e|
|
20
|
-
e.
|
21
|
-
e.
|
22
|
-
e.
|
20
|
+
e.value :name => 'red'
|
21
|
+
e.value :name => 'green'
|
22
|
+
e.value :name => 'blue'
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
data/lib/easy_enums.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
|
2
2
|
module EasyEnumerations
|
3
|
-
VERSION = '0.0.
|
3
|
+
VERSION = '0.0.2'
|
4
4
|
|
5
5
|
def self.included(base)
|
6
6
|
base.extend(ClassMethods)
|
@@ -44,8 +44,8 @@ module EasyEnumerations
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def each_name
|
47
|
-
all.each do |
|
48
|
-
yield
|
47
|
+
all.each do |obj|
|
48
|
+
yield obj.name
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -55,7 +55,7 @@ module EasyEnumerations
|
|
55
55
|
@model = model
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
58
|
+
def value(options)
|
59
59
|
unless @model.exists?(:name => options[:name])
|
60
60
|
@model.create!(options)
|
61
61
|
end
|
data/test/test_easy_enums.rb
CHANGED
@@ -37,9 +37,9 @@ class TestEasyEnums < Test::Unit::TestCase
|
|
37
37
|
include EasyEnumerations
|
38
38
|
|
39
39
|
enumerates do |e|
|
40
|
-
e.
|
41
|
-
e.
|
42
|
-
e.
|
40
|
+
e.value :name => 'red'
|
41
|
+
e.value :name => 'green'
|
42
|
+
e.value :name => 'blue'
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -48,10 +48,10 @@ class TestEasyEnums < Test::Unit::TestCase
|
|
48
48
|
include EasyEnumerations
|
49
49
|
|
50
50
|
enumerates do |e|
|
51
|
-
e.
|
52
|
-
e.
|
53
|
-
e.
|
54
|
-
e.
|
51
|
+
e.value :name => 'Spring'
|
52
|
+
e.value :name => 'Summer'
|
53
|
+
e.value :name => 'Fall'
|
54
|
+
e.value :name => 'Winter'
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|