lib/soapy_cake/response.rb in soapy_cake-1.6.8 vs lib/soapy_cake/response.rb in soapy_cake-1.6.9
- old
+ new
@@ -22,21 +22,25 @@
private
def typed_element(element)
walk_tree(element) do |value, key|
- next value.to_i if key.to_s.end_with?('_id') && !key.to_s.end_with?('tax_id')
+ parse_element(key, value)
+ end
+ end
- if /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.?\d*\z/.match(value)
- next DateTime.parse(value + format('%+03d:00', time_offset.to_i))
- end
+ def parse_element(key, value)
+ return value.to_i if key.to_s.end_with?('_id') && !key.to_s.end_with?('tax_id')
+ return false if value == 'false'
+ return true if value == 'true'
+ return parse_date(value) if /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.?\d*\z/.match(value)
- next false if value == 'false'
- next true if value == 'true'
+ # cast to primitive string to get rid of Saxerator string class
+ value.to_s
+ end
- # cast to primitive string to get rid of Saxerator string class
- value.to_s
- end
+ def parse_date(value)
+ DateTime.parse(value + format('%+03d:00', time_offset.to_i))
end
def sax
@sax ||= Saxerator.parser(StringIO.new(body)) do |config|
config.symbolize_keys!