Class: Sunspot::Query::Connective::Disjunction
- Defined in:
- lib/sunspot/query/connective.rb
Overview
Disjunctions combine their components with an OR operator.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_conjunction ⇒ Object
Add a conjunction to the disjunction.
-
#add_disjunction ⇒ Object
No-op - this is already a disjunction.
-
#to_boolean_phrase ⇒ Object
Express this disjunction as a Lucene boolean phrase.
Methods inherited from Abstract
#initialize, #negate, #negated?, #to_params
Methods inherited from Scope
#add_component, #add_negated_restriction, #add_negated_shorthand_restriction, #add_restriction, #add_shorthand_restriction, #dynamic_query, #exclude_instance, #initialize, #to_params
Constructor Details
This class inherits a constructor from Sunspot::Query::Connective::Abstract
Class Method Details
.inverse ⇒ Object
72 73 74 |
# File 'lib/sunspot/query/connective.rb', line 72 def inverse Conjunction end |
Instance Method Details
#add_conjunction ⇒ Object
Add a conjunction to the disjunction. This overrides the method in the Scope class since scopes are implicitly conjunctive and thus can return themselves as a conjunction. Inside a disjunction, however, a conjunction must explicitly be created.
94 95 96 97 |
# File 'lib/sunspot/query/connective.rb', line 94 def add_conjunction @components << conjunction = Conjunction.new(@setup) conjunction end |
#add_disjunction ⇒ Object
No-op - this is already a disjunction
102 103 104 |
# File 'lib/sunspot/query/connective.rb', line 102 def add_disjunction self end |
#to_boolean_phrase ⇒ Object
Express this disjunction as a Lucene boolean phrase
80 81 82 83 84 85 86 |
# File 'lib/sunspot/query/connective.rb', line 80 def to_boolean_phrase if @components.any? { |component| component.negated? } denormalize.to_boolean_phrase else super end end |