| Class | AWS::Record::Scope |
| In: |
lib/aws/record/scope.rb
|
| Parent: | Object |
Base class for {AWS::Record::Model::Scope} and {AWS::Record::HashModel::Scope}.
| base_class | [R] |
@return [Class] Returns the AWS::Record::Model
extending class that
this scope will find records for. |
@param base_class A class that extends {AWS::Record::AbstractBase}. @param [Hash] options @option options : @private
Yields once for each record matching the request made by this scope.
books = Book.where(:author => 'me').order(:price, :asc).limit(10)
books.each do |book|
puts book.attributes.to_yaml
end
@yieldparam [Object] record
@overload find(id)
Finds and returns a single record by id. If no record is found with the given +id+, then a RecordNotFound error will be raised. @param [String] id ID of the record to find. @return Returns the record.
@overload find(:first, options = {})
Returns the first record found. If no records were matched then
nil will be returned (raises no exceptions).
@param [Symbol] mode (:first)
@return [Object,nil] Returns the first record or nil if no
records matched the conditions.
@overload find(:all, options = {})
Returns an enumerable Scope object that represents all matching
records. No request is made to AWS until the scope is enumerated.
Book.find(:all, :limit => 100).each do |book|
# ...
end
@param [Symbol] mode (:all)
@return [Scope] Returns an enumerable scope object.
@return Returns the first record found, returns
nil if the domain/table is empty.