lib/aws/record/model.rb in aws-sdk-1.12.0 vs lib/aws/record/model.rb in aws-sdk-1.13.0

- old
+ new

@@ -271,10 +271,26 @@ require 'aws/record/model/finder_methods' require 'aws/record/model/scope' extend AbstractBase + # The id for each record is auto-generated. The default strategy + # generates uuid strings. + # @return [String] Returns the id string (uuid) for this record. Retuns + # nil if this is a new record that has not been persisted yet. + def id + @_id + end + + # @return [Hash] A hash with attribute names as hash keys (strings) and + # attribute values (of mixed types) as hash values. + def attributes + attributes = super + attributes['id'] = id if persisted? + attributes + end + class << self # Creates the SimpleDB domain that is configured for this class. # # class Product < AWS::Record::Model @@ -370,9 +386,19 @@ data[attr_name] = attribute.deserialize(values.first) end end data + end + + def hydrate(id, data) + @_id = id + super + end + + # @api private + def populate_id + @_id = UUIDTools::UUID.random_create.to_s.downcase end # @api private protected def create_storage