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

Instance Method Summary collapse

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_optionsObject

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 count_options
  self.class.scope_for_count.to_options(self)
end

#find_optionsObject

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 find_options
  self.class.scope_for_find.to_options(self)
end