Module: AWS::S3::Parsing::Typecasting
- Included in:
- XmlParser
- Defined in:
- lib/aws-matt/s3/parsing.rb
Instance Method Summary collapse
Instance Method Details
#typecast(object) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/aws-matt/s3/parsing.rb', line 16 def typecast(object) case object when Hash typecast_hash(object) when Array object.map {|element| typecast(element)} when String CoercibleString.coerce(object) else object end end |
#typecast_hash(hash) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/aws-matt/s3/parsing.rb', line 29 def typecast_hash(hash) if content = hash['__content__'] typecast(content) else keys = hash.keys.map {|key| key.underscore} values = hash.values.map {|value| typecast(value)} keys.inject({}) do |new_hash, key| new_hash[key] = values.slice!(0) new_hash end end end |