Skip to content

Commit

Permalink
Merge pull request #23 from jmcnally/master
Browse files Browse the repository at this point in the history
Update enum_column for Rails 4.1
  • Loading branch information
electronick committed Aug 21, 2014
2 parents c363805 + 78b648e commit e0d80f1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/enum/enum_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ def type_cast(value)
end
end

alias __type_cast_code_enum type_cast_code
# Code to convert to a symbol.
def type_cast_code(var_name)
if type == :enum
"#{self.class.name}.value_to_symbol(#{var_name})"
else
__type_cast_code_enum(var_name)
if respond_to?(:type_cast_code)
alias __type_cast_code_enum type_cast_code
# Code to convert to a symbol.
def type_cast_code(var_name)
if type == :enum
"#{self.class.name}.value_to_symbol(#{var_name})"
else
__type_cast_code_enum(var_name)
end
end
end

Expand Down

0 comments on commit e0d80f1

Please sign in to comment.