Module AWS::Record::AbstractBase::InstanceMethods
In: lib/aws/record/abstract_base.rb

Methods

Public Class methods

Constructs a new record.

@param [Hash] attributes A set of attribute values to seed this record

  with.  The attributes are bulk assigned.

@param [Hash] attributes Attributes that should be bulk assigned

  to this record.  You can also specify the shard (i.e. domain
  or table) this record should persist to via +:shard+).

@option attributes [String] :shard The domain/table this record

  should persist to.  If this is omitted, it will persist to the
  class default shard (which defaults to the class name).

@return [Model,HashModel] Returns a new (non-persisted) record.

  Call {#save} to persist changes to AWS.

Public Instance methods

@return [Hash] A hash with attribute names as hash keys (strings) and

  attribute values (of mixed types) as hash values.

Acts like {update} but does not call {save}.

  record.attributes = { :name => 'abc', :age => 20 }

@param [Hash] attributes A hash of attributes to set on this record

  without calling save.

@return [Hash] Returns the attribute hash that was passed in.

Deletes the record. @return [true]

@return [Boolean] Returns true if this instance object has been deleted.

destroy()

Alias for delete

domain()

Alias for shard

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.

@return [Boolean] Returns true if this record has not been persisted

  to SimpleDB.

Persistence indicates if the record has been saved previously or not.

@example

  @recipe = Recipe.new(:name => 'Buttermilk Pancackes')
  @recipe.persisted? #=> false
  @recipe.save!
  @recipe.persisted? #=> true

@return [Boolean] Returns true if this record has been persisted.

Creates new records, updates existing records. @return [Boolean] Returns true if the record saved without errors,

  false otherwise.

Creates new records, updates exsting records. If there is a validation error then an exception is raised. @raise [InvalidRecordError] Raised when the record has validation

  errors and can not be saved.

@return [true] Returns true after a successful save.

@return [String] Returns the name of the shard this record

  is persisted to or will be persisted to.  Defaults to the
  domain/table named after this record class.

Bulk assigns the attributes and then saves the record. @param [Hash] attribute_hash A hash of attribute names (keys) and

  attribute values to assign to this record.

@return (see save)

Bulk assigns the attributes and then saves the record. Raises an exception (AWS::Record::InvalidRecordError) if the record is not valid. @param (see update_attributes) @return [true]

@return [Boolean] Returns true if this record has no validation errors.

Protected Instance methods

Returns the typecasted value for the named attribute.

  book = Book.new(:title => 'My Book')
  book['title'] #=> 'My Book'
  book.title    #=> 'My Book'

Intended Use

This method‘s primary use is for getting/setting the value for an attribute inside a custom method:

  class Book < AWS::Record::Model

    string_attr :title

    def title
      self['title'] ? self['title'].upcase : nil
    end

  end

  book = Book.new(:title => 'My Book')
  book.title    #=> 'MY BOOK'

@param [String,Symbol] attribute_name The name of the attribute to fetch

  a value for.

@return The current type-casted value for the named attribute.

If you define a custom setter, you use #[]= to set the value on the record.

  class Book < AWS::Record::Model

    string_attr :name

    # replace the default #author= method
    def author= name
      self['author'] = name.blank? ? 'Anonymous' : name
    end

  end

@param [String,Symbol] The attribute name to set a value for @param attribute_value The value to assign.

[Validate]