Skip to content

Commit e0d80f1

Browse files
committed
Merge pull request #23 from jmcnally/master
Update enum_column for Rails 4.1
2 parents c363805 + 78b648e commit e0d80f1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/enum/enum_adapter.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@ def type_cast(value)
3737
end
3838
end
3939

40-
alias __type_cast_code_enum type_cast_code
41-
# Code to convert to a symbol.
42-
def type_cast_code(var_name)
43-
if type == :enum
44-
"#{self.class.name}.value_to_symbol(#{var_name})"
45-
else
46-
__type_cast_code_enum(var_name)
40+
if respond_to?(:type_cast_code)
41+
alias __type_cast_code_enum type_cast_code
42+
# Code to convert to a symbol.
43+
def type_cast_code(var_name)
44+
if type == :enum
45+
"#{self.class.name}.value_to_symbol(#{var_name})"
46+
else
47+
__type_cast_code_enum(var_name)
48+
end
4749
end
4850
end
4951

0 commit comments

Comments
 (0)