Skip to content

Commit

Permalink
Pass time & money values through cast.
Browse files Browse the repository at this point in the history
  • Loading branch information
hopsoft committed Apr 2, 2014
1 parent 8f4c621 commit 362a6bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ test/version_tmp
tmp
.DS_Store
.ruby-version
tags
8 changes: 6 additions & 2 deletions lib/field_mapper/standard/field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@ def cast_value(type, value, as_single_value: false)
case type.name
when "String" then return value.to_s.strip
when "FieldMapper::Types::Boolean" then return FieldMapper::Types::Boolean.parse(value)
when "Time" then return Time.parse(value.to_s) rescue nil # TODO: log error?
when "Time" then
return value if value.is_a?(Time)
return Time.parse(value.to_s) rescue nil
when "Integer" then return value.to_i
when "Float" then return value.to_f
when "Money" then return Monetize.parse(value) rescue nil # TODO: log error?
when "Money" then
return value if value.is_a?(Money)
return Monetize.parse(value) rescue nil
when "FieldMapper::Types::Plat" then return plat_instance(type, value)
when "FieldMapper::Types::List" then
return value if value.is_a?(Array) && value.empty?
Expand Down
2 changes: 1 addition & 1 deletion lib/field_mapper/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module FieldMapper
VERSION = "0.1.0"
VERSION = "0.1.1"
end

0 comments on commit 362a6bd

Please sign in to comment.