AWS services or capabilities described in AWS Documentation may vary by region/location. Click
Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Class: Aws::Record::Marshalers::MapMarshaler
- Inherits:
-
Object
- Object
- Aws::Record::Marshalers::MapMarshaler
show all
- Defined in:
- lib/aws-record/record/marshalers/map_marshaler.rb
Instance Method Summary
collapse
Constructor Details
#initialize(opts = {}) ⇒ MapMarshaler
Returns a new instance of MapMarshaler.
19
20
|
# File 'lib/aws-record/record/marshalers/map_marshaler.rb', line 19
def initialize(opts = {})
end
|
Instance Method Details
#serialize(raw_value) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/aws-record/record/marshalers/map_marshaler.rb', line 41
def serialize(raw_value)
map = type_cast(raw_value)
if map.is_a?(Hash)
map
elsif map.nil?
nil
else
msg = "expected a Hash value or nil, got #{map.class}"
raise ArgumentError, msg
end
end
|
#type_cast(raw_value) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/aws-record/record/marshalers/map_marshaler.rb', line 22
def type_cast(raw_value)
case raw_value
when nil
nil
when ''
nil
when Hash
raw_value
else
if raw_value.respond_to?(:to_h)
raw_value.to_h
else
msg = "Don't know how to make #{raw_value} of type"\
" #{raw_value.class} into a hash!"
raise ArgumentError, msg
end
end
end
|