Class: DataMapper::Types::SdbArray
- Inherits:
-
DataMapper::Type
- Object
- DataMapper::Type
- DataMapper::Types::SdbArray
- Defined in:
- lib/dm-adapter-simpledb/sdb_array.rb
Class Method Summary collapse
Class Method Details
.dump(value, property) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dm-adapter-simpledb/sdb_array.rb', line 22 def self.dump(value, property) dumped = ::Object.new # This is a little screwy. DataMapper has a fixed list of values it # considers primitives, and it insists that the value that comes out of # a type's .dump() method MUST match one of these types. For SimpleDB # Array is effectively a primitive because of the way it stores values, # but DM doesn't include Array in it's list of valid primtive types. So # we need to return an object which IS considered a primitive - in this # case a plain 'ole Ruby Object. In order to convey the actual array # value to the backend, we tack on a #to_ary method which returns the # array data. Aws calls Array() on all values before writing them, # which in turn calls #to_ary(), and winds up with the correct data. In # effect we are sneaking the array data through DataMapper inside a # singleton method. singleton_class = (class << dumped; self; end) singleton_class.send(:define_method, :to_ary) do value end singleton_class.send(:define_method, :to_s) do value.to_s end dumped end |
.load(value, property) ⇒ Object
18 19 20 |
# File 'lib/dm-adapter-simpledb/sdb_array.rb', line 18 def self.load(value, property) value end |
.typecast(value, property) ⇒ Object
46 47 48 |
# File 'lib/dm-adapter-simpledb/sdb_array.rb', line 46 def self.typecast(value, property) value end |