Permalink
Browse files

Don't convert value if it's already of an appropriate type.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5013 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 899c1b0 commit 7cdd0d6ecf6afe0af98faf52e40b40deb5a15384 Kent Sibilev committed Sep 5, 2006
Showing with 6 additions and 6 deletions.
  1. +6 −6 actionwebservice/lib/action_web_service/casting.rb
@@ -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

0 comments on commit 7cdd0d6

Please sign in to comment.