Module: ActiveCollection::Scope
- Defined in:
- lib/active_collection/scope.rb,
lib/active_collection/new_scope.rb
Defined Under Namespace
Modules: ClassMethods Classes: ScopeBuilder
Class Method Summary collapse
-
.included(mod) ⇒ Object
extend ActiveSupport::Concern.
Instance Method Summary collapse
-
#count_options ⇒ Object
Count options for loading the total count.
-
#find_options ⇒ Object
Find options for loading the collection.
Class Method Details
.included(mod) ⇒ Object
extend ActiveSupport::Concern
7 8 9 |
# File 'lib/active_collection/scope.rb', line 7 def self.included(mod) mod.extend ClassMethods end |
Instance Method Details
#count_options ⇒ Object
Count options for loading the total count.
To add more options, define a method that returns a hash with the additional options for count and then add it like this:
class BeerCollection
count_scope :awesome_beer_only
def awesome_beer_only
{ :conditions => "beer = 'awesome'" }
end
end
41 42 43 |
# File 'lib/active_collection/scope.rb', line 41 def self.class.scope_for_count.(self) end |
#find_options ⇒ Object
Find options for loading the collection.
To add more options, define a method that returns a hash with the additional options for find and then add it like this:
class BeerCollection
find_scope :awesome_beer_only
def awesome_beer_only
{ :conditions => "beer = 'awesome'" }
end
end
24 25 26 |
# File 'lib/active_collection/scope.rb', line 24 def self.class.scope_for_find.(self) end |