lib/dynamoid/persistence.rb
def dump_field(value, options)
      if (field_class = options[:type]).is_a?(Class)
        if value.respond_to?(:dynamoid_dump)
          value.dynamoid_dump
        elsif field_class.respond_to?(:dynamoid_dump)
          field_class.dynamoid_dump(value)
        else
          raise ArgumentError, "Neither #{field_class} nor #{value} support serialization for Dynamoid."
        end
      else
        case options[:type]
          when :string
            !value.nil? ? value.to_s : nil
          when :integer
            !value.nil? ? Integer(value) : nil
          when :number
            !value.nil? ? value : nil
          when :set
            !value.nil? ? Set.new(value) : nil
          when :array
            !value.nil? ? value : nil
          when :datetime
            !value.nil? ? value.to_time.to_f : nil
          when :serialized
            options[:serializer] ? options[:serializer].dump(value) : value.to_yaml
          when :boolean
            !value.nil? ? value.to_s[0] : nil
          else
            raise ArgumentError, "Unknown type #{options[:type]}"
        end
      end
    end
# Determine how to dump this field. Given a value, it'll determine how to turn it into a value that can be
# persisted into the datastore.
#
# @since 0.2.0
Determine how to dump this field. Given a value, it'll determine how to turn it into a value that can be
persisted into the datastore.
Determine how to dump this field . Given a value it ' ll determine how to turn it into a value that can be persisted into the datastore .
def dump_field(value, options)
      if (field_class = options[:type]).is_a?(Class)
        if value.respond_to?(:dynamoid_dump)
          value.dynamoid_dump
        elsif field_class.respond_to?(:dynamoid_dump)
          field_class.dynamoid_dump(value)
        else
          raise ArgumentError, "Neither #{field_class} nor #{value} support serialization for Dynamoid."
        end
      else
        case options[:type]
          when :string
            !value.nil? ? value.to_s : nil
          when :integer
            !value.nil? ? Integer(value) : nil
          when :number
            !value.nil? ? value : nil
          when :set
            !value.nil? ? Set.new(value) : nil
          when :array
            !value.nil? ? value : nil
          when :datetime
            !value.nil? ? value.to_time.to_f : nil
          when :serialized
            options[:serializer] ? options[:serializer].dump(value) : value.to_yaml
          when :boolean
            !value.nil? ? value.to_s[0] : nil
          else
            raise ArgumentError, "Unknown type #{options[:type]}"
        end
      end
    end
def dump_field ( value , options ) if ( field_class = options [ :type ] ) . is_a? ( Class ) if value . respond_to? ( :dynamoid_dump ) value . dynamoid_dump elsif field_class . respond_to? ( :dynamoid_dump ) field_class . dynamoid_dump ( value ) else raise ArgumentError , "Neither #{field_class} nor #{value} support serialization for Dynamoid." end else case options [ :type ] when :string ! value . nil? ? value . to_s : nil when :integer ! value . nil? ? Integer ( value ) : nil when :number ! value . nil? ? value : nil when :set ! value . nil? ? Set . new ( value ) : nil when :array ! value . nil? ? value : nil when :datetime ! value . nil? ? value . to_time . to_f : nil when :serialized options [ :serializer ] ? options [ :serializer ] . dump ( value ) : value . to_yaml when :boolean ! value . nil? ? value . to_s [ 0 ] : nil else raise ArgumentError , "Unknown type #{options[:type]}" end end end
Determine how to dump this field.
Determine how to dump this field .
value
options
since
None