Refactoring the limit method

This commit is contained in:
Rafael Mendonça França 2012-04-21 09:10:36 -03:00
parent 1ff7f20d66
commit 1f8a90ee9b
1 changed files with 7 additions and 4 deletions

View File

@ -87,19 +87,22 @@ module SimpleForm
end
def limit
decimal_or_float? ? decimal_limit : column_limit
if column
decimal_or_float? ? decimal_limit : column_limit
end
end
def column_limit
column && column.limit
column.limit
end
# Add one for decimal point
def decimal_limit
column_limit && (column_limit + 1) #for decimal point
column_limit && (column_limit + 1)
end
def decimal_or_float?
column && column.number? && column.type != :integer
column.number? && column.type != :integer
end
def nested_boolean_style?