Module: Supernova::ClassMethods

Defined in:
lib/supernova.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#criteria_classObject

Returns the value of attribute criteria_class.



13
14
15
# File 'lib/supernova.rb', line 13

def criteria_class
  @criteria_class
end

#defined_named_search_scopesObject

Returns the value of attribute defined_named_search_scopes.



13
14
15
# File 'lib/supernova.rb', line 13

def defined_named_search_scopes
  @defined_named_search_scopes
end

Instance Method Details

#named_search_scope(name, &block) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/supernova.rb', line 19

def named_search_scope(name, &block)
  self.class.send(:define_method, name) do |*args|
    self.search_scope.instance_exec(*args, &block)
  end
  self.defined_named_search_scopes ||= []
  self.defined_named_search_scopes << name
end

#search_scopeObject



15
16
17
# File 'lib/supernova.rb', line 15

def search_scope
  self.criteria_class.new(self).named_scope_class(self)
end