Class: Aws::Record::Marshalers::BooleanMarshaler
- Inherits:
-
Object
- Object
- Aws::Record::Marshalers::BooleanMarshaler
- Defined in:
- lib/aws-record/record/marshalers/boolean_marshaler.rb
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ BooleanMarshaler
constructor
A new instance of BooleanMarshaler.
- #serialize(raw_value) ⇒ Object
- #type_cast(raw_value) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ BooleanMarshaler
Returns a new instance of BooleanMarshaler.
8 9 |
# File 'lib/aws-record/record/marshalers/boolean_marshaler.rb', line 8 def initialize(opts = {}) end |
Instance Method Details
#serialize(raw_value) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/aws-record/record/marshalers/boolean_marshaler.rb', line 24 def serialize(raw_value) boolean = type_cast(raw_value) case boolean when nil nil when false false when true true else msg = "expected a boolean value or nil, got #{boolean.class}" raise ArgumentError, msg end end |
#type_cast(raw_value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/aws-record/record/marshalers/boolean_marshaler.rb', line 11 def type_cast(raw_value) case raw_value when nil nil when '' nil when false, 'false', '0', 0 false else true end end |