Skip to content
Browse files

Add class_name as an option to #classy_enum_attr

  • Loading branch information...
1 parent d8da27a commit bf6f59ecfb693f92e8af8708746b86fe718db857 @jordpo jordpo committed May 22, 2014
Showing with 2 additions and 2 deletions.
  1. +1 −1 lib/classy_enum/active_record.rb
  2. +1 −1 spec/classy_enum/active_record_spec.rb
View
2 lib/classy_enum/active_record.rb
@@ -53,7 +53,7 @@ module ActiveRecord
# # Specifying a default enum value
# classy_enum_attr :priority, :default => 'low'
def classy_enum_attr(attribute, options={})
- enum = (options[:enum] || attribute).to_s.camelize.constantize
+ enum = (options[:enum] || options[:class_name] || attribute).to_s.camelize.constantize
allow_blank = options[:allow_blank] || false
allow_nil = options[:allow_nil] || false
serialize_as_json = options[:serialize_as_json] || false
View
2 spec/classy_enum/active_record_spec.rb
@@ -53,7 +53,7 @@ class AllowNilBreedDog < Dog
end
class OtherDog < Dog
- classy_enum_attr :other_breed, :enum => 'Breed'
+ classy_enum_attr :other_breed, :class_name => 'Breed'
end
describe DefaultDog do

0 comments on commit bf6f59e

Please sign in to comment.
Something went wrong with that request. Please try again.