Module: Searchlogic::NamedScopes::AssociationConditions
- Defined in:
- lib/searchlogic/named_scopes/association_conditions.rb
Overview
Handles dynamically creating named scopes for associations. See the README for a detailed explanation.
Instance Method Summary collapse
- #_resolve_deep_association_conditions(condition_name, args) ⇒ Object
-
#condition?(name) ⇒ Boolean
:nodoc:.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object (private)
30 31 32 33 34 35 36 37 |
# File 'lib/searchlogic/named_scopes/association_conditions.rb', line 30 def method_missing(name, *args, &block) if !local_condition?(name) && details = association_condition_details(name) create_scope_for_association(details[:association], details[:condition], args, details[:poly_class]) send(name, *args) else super end end |
Instance Method Details
#_resolve_deep_association_conditions(condition_name, args) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/searchlogic/named_scopes/association_conditions.rb', line 9 def _resolve_deep_association_conditions(condition_name, args) if local_condition?(condition_name) {:joins=>nil, :klass=>self, :condition=>condition_name} elsif details = association_condition_details(condition_name) result = details[:association].klass._resolve_deep_association_conditions(details[:condition], args) return nil unless result #condition method did not resolve this_association = details[:association].name join_condition = result[:joins].nil? ? this_association : {this_association=>result[:joins]} result.merge(:joins=>join_condition) else #this condition method did not resolve nil end end |
#condition?(name) ⇒ Boolean
:nodoc:
5 6 7 |
# File 'lib/searchlogic/named_scopes/association_conditions.rb', line 5 def condition?(name) # :nodoc: super || association_condition?(name) end |