Class: DmAdapterSimpledb::RecordV0

Inherits:
Record
  • Object
show all
Defined in:
lib/dm-adapter-simpledb/record.rb

Overview

Version 0 records are records that have no associated version metadata. Any records created by versions of the DataMapper/SimplDB adapter prior to 1.1.0 are considered to be version 0.

Version 0 records have a few distinguishing characteristics:

* An attribute with the token "nil" as its sole member is treated as a
  null/empty attribute.
* The token "[[[NEWLINE]]]" inside of String attributes is replaced with \n

Constant Summary

Constants inherited from Record

DmAdapterSimpledb::Record::CURRENT_VERSION, DmAdapterSimpledb::Record::METADATA_KEY, DmAdapterSimpledb::Record::META_KEYS, DmAdapterSimpledb::Record::STORAGE_NAME_KEY

Instance Attribute Summary

Attributes inherited from Record

#deletable_attributes, #item_name, #simpledb_attributes

Instance Method Summary collapse

Methods inherited from Record

#[], #add_metadata_to!, #coerce_to, #coerce_to_property, data_version, from_resource, from_simpledb_hash, #initialize, #metadata, #migrate, register, simpledb_attributes, #storage_name, #table, #table_name_from_model, #to_resource_hash, #version, version, #version_token, versions

Methods included from Utils

#transform_hash

Constructor Details

This class inherits a constructor from DmAdapterSimpledb::Record

Instance Method Details

#coerce_to_type(values, type) ⇒ Object



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/dm-adapter-simpledb/record.rb', line 299

def coerce_to_type(values, type)
  values = values.map{|v| replace_newline_placeholders(v)}
  result = super(values, type)

  if result == "nil"
    nil
  elsif result == ["nil"]
    []
  elsif result && type <= String
    # TODO redundant
    replace_newline_placeholders(result)
  else
    result
  end
end