class Aws::Record::Marshalers::BooleanMarshaler

Public Class Methods

new(opts = {}) click to toggle source
# File lib/aws-record/record/marshalers/boolean_marshaler.rb, line 19
def initialize(opts = {})
end

Public Instance Methods

serialize(raw_value) click to toggle source
# File lib/aws-record/record/marshalers/boolean_marshaler.rb, line 35
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) click to toggle source
# File lib/aws-record/record/marshalers/boolean_marshaler.rb, line 22
def type_cast(raw_value)
  case raw_value
  when nil
    nil
  when ''
    nil
  when false, 'false', '0', 0
    false
  else
    true
  end
end