Module | AWS::Record::AbstractBase::ClassMethods |
In: |
lib/aws/record/abstract_base.rb
|
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.
Allows you to override the default shard name for this class. The shard name defaults to the class name. @param [String] name