Permalink
Browse files

Added Integer conversion support for has_details plugin, a bit more c…

…rude, but similiar to what activerecord has
  • Loading branch information...
1 parent b2b60ce commit af4305a7abcab534efd3b8737b3ef5a8dc44de4b @tarmo tarmo committed with erkki Nov 17, 2008
Showing with 2 additions and 0 deletions.
  1. +2 −0 lib/has_details.rb
View
@@ -46,6 +46,8 @@ def has_details(options = {})
elsif t == :boolean
# everything can be converted to boolean so we don't have an exception here
"val = ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(val) unless val.nil?"
+ elsif t == Integer
+ "val = Integer(val) rescue nil"
else
"raise \"Assigned value must be a #{t.inspect}\" unless val.nil? || val.is_a?(#{t.inspect})"
end

0 comments on commit af4305a

Please sign in to comment.