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::IntegerMarshaler
- Inherits:
-
Object
- Object
- Aws::Record::Marshalers::IntegerMarshaler
show all
- Defined in:
- lib/aws-record/record/marshalers/integer_marshaler.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of IntegerMarshaler.
19
20
|
# File 'lib/aws-record/record/marshalers/integer_marshaler.rb', line 19
def initialize(opts = {})
end
|
Instance Method Details
#serialize(raw_value) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/aws-record/record/marshalers/integer_marshaler.rb', line 37
def serialize(raw_value)
integer = type_cast(raw_value)
if integer.nil?
nil
elsif integer.is_a?(Integer)
integer
else
msg = "expected an Integer value or nil, got #{integer.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
|
# File 'lib/aws-record/record/marshalers/integer_marshaler.rb', line 22
def type_cast(raw_value)
case raw_value
when nil
nil
when ''
nil
when Integer
raw_value
else
raw_value.respond_to?(:to_i) ?
raw_value.to_i :
raw_value.to_s.to_i
end
end
|