Module: Searchlogic::NamedScopes::Ordering
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/searchlogic/named_scopes/ordering.rb
Overview
Handles dynamically creating named scopes for orderin by columns.
Instance Method Summary collapse
-
#local_condition?(name) ⇒ Boolean
:nodoc:.
-
#primary_condition_name(name) ⇒ Object
:nodoc.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/searchlogic/named_scopes/ordering.rb', line 24 def method_missing(name, *args, &block) if name == :order named_scope name, lambda { |scope_name| return {} if !condition?(scope_name) send(scope_name). } send(name, *args) elsif details = ordering_condition_details(name) create_ordering_conditions(details[:column]) send(name, *args) else super end end |
Instance Method Details
#local_condition?(name) ⇒ Boolean
:nodoc:
5 6 7 |
# File 'lib/searchlogic/named_scopes/ordering.rb', line 5 def local_condition?(name) # :nodoc: super || order_condition?(name) end |
#primary_condition_name(name) ⇒ Object
:nodoc
9 10 11 12 13 14 15 16 17 |
# File 'lib/searchlogic/named_scopes/ordering.rb', line 9 def primary_condition_name(name) # :nodoc if result = super result elsif ordering_condition?(name) name.to_sym else nil end end |