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

Methods

Public Instance methods

@return [Hash<String,Attribute>] Returns a hash of all of the

  configured attributes for this class.

Creates an object (or multiple if you pass an array of attributes). The {save} method is called on the object(s) after construction. The object(s) are returned wether or not the object(s) are valid.

    class Book < AWS::Record::Model
      string_attr :title
    end

    book = Book.create(:title => "The big book of tests")
    book.persisted?
    #=> true

    books = Book.create([{:title => 'abc'}, {:title => 'xyz'}])
    books.each(&:persisted?)
    #=> [true, true]

Creates an object (or multiple if you pass an array of attributes). The {save!} method is called on the object(s) after construction. If the object(s) are not valid, then an error is raised.

    class Book < AWS::Record::Model
      string_attr :title
      validates_presence_of :title
    end

    book = Book.create!(:title => "The big book of tests")
    book.persisted?
    #=> true

    book = Book.create!()
    #=> raises AWS::Record::InvalidRecordError
domain_name(name = nil)

Alias for shard_name

@api private

@return [Boolean] Returns true if this class is configured to

  perform optimistic locking.

Adds a scoped finder to this class.

    class Book < AWS::Record::Model
      scope :top_10, order(:popularity, :desc).limit(10)
    end

    Book.top_10.to_a
    #=> [#<Book...>, #<Book...>]

    Book.top_10.first
    #=> #<Book...>

You can also provide a block that accepts params for the scoped finder. This block should return a scope.

    class Book < AWS::Record::Model
      scope :by_author, lambda {|name| where(:author => name) }
    end

    # top 10 books by the author 'John Doe'
    Book.by_author('John Doe').top_10

@param [Symbol] name The name of the scope. Scope names should be

  method-safe and should not conflict with any other class methods.

@param [Scope] scope

set_domain_name(name)

Alias for set_shard_name

Allows you to override the default shard name for this class. The shard name defaults to the class name. @param [String] name

Returns the name of the shard this class will persist records into by default.

@param [String] name Defaults to the name of this class. @return [String] Returns the full prefixed domain name for this class.

shard_name=(name)

Alias for set_shard_name

[Validate]