class Aws::Record::Marshalers::ListMarshaler

Public Class Methods

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

Public Instance Methods

serialize(raw_value) click to toggle source
# File lib/aws-record/record/marshalers/list_marshaler.rb, line 41
def serialize(raw_value)
  list = type_cast(raw_value)
  if list.is_a?(Array)
    list
  elsif list.nil?
    nil
  else
    msg = "expected an Array value or nil, got #{list.class}"
    raise ArgumentError, msg
  end
end
type_cast(raw_value) click to toggle source
# File lib/aws-record/record/marshalers/list_marshaler.rb, line 22
def type_cast(raw_value)
  case raw_value
  when nil
    nil
  when ''
    nil
  when Array
    raw_value
  else
    if raw_value.respond_to?(:to_a)
      raw_value.to_a
    else
      msg = "Don't know how to make #{raw_value} of type"\
        " #{raw_value.class} into an array!"
      raise ArgumentError, msg
    end
  end
end