1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00
fog--fog-aws/lib/fog/aws/parsers/lambda/base.rb
2015-06-23 09:53:53 -03:00

39 lines
893 B
Ruby

module Fog
module AWS
module Parsers
module Lambda
class Base
def process(body)
body.inject({}) { |h, (k, v)| h[k] = rules(k, v); h }
end
private
def rules(key, value)
case value
when Hash
process(value)
when Array
value.map { |i| process(i) }
else
case key
when 'LastModified'
Time.parse(value)
when 'Policy', 'Statement'
begin
Fog::JSON.decode(value)
rescue Fog::JSON::DecodeError => e
Fog::Logger.warning("Error parsing response json - #{e}")
{}
end
else
value
end
end
end
end
end
end
end
end