Class: Sunspot::Query::Restriction::SameAs

Inherits:
Base
  • Object
show all
Defined in:
lib/sunspot/query/restriction.rb

Overview

Result must be the exact instance given (only useful when negated).

Instance Method Summary collapse

Methods inherited from Base

#negated?, #to_boolean_phrase, #to_negated_boolean_phrase, #to_params

Constructor Details

#initialize(object, negated = false) ⇒ SameAs

Returns a new instance of SameAs.



218
219
220
# File 'lib/sunspot/query/restriction.rb', line 218

def initialize(object, negated = false)
  @object, @negated = object, negated
end

Instance Method Details

#negateObject



227
228
229
# File 'lib/sunspot/query/restriction.rb', line 227

def negate
  SameAs.new(@object, !negated?)
end

#to_positive_boolean_phraseObject



222
223
224
225
# File 'lib/sunspot/query/restriction.rb', line 222

def to_positive_boolean_phrase
  adapter = Adapters::InstanceAdapter.adapt(@object)
  "id:#{escape(adapter.index_id)}"
end