Skip to content

Commit

Permalink
Don't convert value if it's already of an appropriate type.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5013 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
Kent Sibilev committed Sep 5, 2006
1 parent 899c1b0 commit 7cdd0d6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions actionwebservice/lib/action_web_service/casting.rb
Expand Up @@ -96,14 +96,14 @@ def cast_base_type(value, signature_type) # :nodoc:
when :float
Float(value)
when :time
value = "#{value['2']}/#{value['3']}/#{value['1']} #{value['4']}:#{value['5']}:#{value['6']}" if value.kind_of?(Hash)
Time.parse(value.to_s)
value = "%s/%s/%s %s:%s:%s" % value.values_at(*%w[2 3 1 4 5 6]) if value.kind_of?(Hash)
value.kind_of?(Time) ? value : Time.parse(value.to_s)
when :date
value = "#{value['2']}/#{value['3']}/#{value['1']}" if value.kind_of?(Hash)
Date.parse(value.to_s)
value = "%s/%s/%s" % value.values_at(*%w[2 3 1]) if value.kind_of?(Hash)
value.kind_of?(Date) ? value : Date.parse(value.to_s)
when :datetime
value = "#{value['2']}/#{value['3']}/#{value['1']} #{value['4']}:#{value['5']}:#{value['6']}" if value.kind_of?(Hash)
DateTime.parse(value.to_s)
value = "%s/%s/%s %s:%s:%s" % value.values_at(*%w[2 3 1 4 5 6]) if value.kind_of?(Hash)
value.kind_of?(DateTime) ? value : DateTime.parse(value.to_s)
end
end

Expand Down

0 comments on commit 7cdd0d6

Please sign in to comment.