mcommons-enum_for 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/enum_for.gemspec +1 -1
- data/lib/enum_for.rb +1 -2
- data/spec/enum_for_spec.rb +0 -4
- metadata +1 -1
data/enum_for.gemspec
CHANGED
data/lib/enum_for.rb
CHANGED
@@ -14,7 +14,7 @@ module EnumFor
|
|
14
14
|
# to +enum_for+.
|
15
15
|
def enum_for(*args)
|
16
16
|
options = args.extract_options!
|
17
|
-
additives = options[:add].respond_to?(:
|
17
|
+
additives = options[:add].respond_to?(:include?) ? options[:add] : ( options[:add].nil? ? [ ] : [ options[:add] ] )
|
18
18
|
attribute = args.first
|
19
19
|
|
20
20
|
plural_attribute = attribute.to_s.pluralize
|
@@ -24,7 +24,6 @@ module EnumFor
|
|
24
24
|
all_valid_values = options[:has].map{|v| v.to_s} | options[:has].map{|v| v.to_sym}
|
25
25
|
|
26
26
|
validates_inclusion_of attribute, options.except(:has, :prefix, :add).merge(:in => all_valid_values )
|
27
|
-
const_set(plural_attribute.upcase, options[:has])
|
28
27
|
|
29
28
|
prefix = options.has_key?(:prefix) ? options[:prefix] : attribute.to_s
|
30
29
|
|
data/spec/enum_for_spec.rb
CHANGED
@@ -51,10 +51,6 @@ describe EnumFor do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
describe "storage and retrieval of possible states in class" do
|
54
|
-
it "should return all possible states when plural of the attribute is called as constant" do
|
55
|
-
Taco::STATES.should == [ :new, :composed, :served, :eaten ]
|
56
|
-
end
|
57
|
-
|
58
54
|
it "should return all possible states when plural of attribute is called as class method" do
|
59
55
|
Taco.states.should == [ :new, :composed, :served, :eaten ]
|
60
56
|
end
|