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.



257
258
259
# File 'lib/sunspot/query/restriction.rb', line 257

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

Instance Method Details

#negateObject



266
267
268
# File 'lib/sunspot/query/restriction.rb', line 266

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

#to_positive_boolean_phraseObject



261
262
263
264
# File 'lib/sunspot/query/restriction.rb', line 261

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