module Elasticsearch::Persistence::SpawnMethods

Public Instance Methods

except(*skips) click to toggle source

Removes from the query the condition(s) specified in skips.

Post.order('id asc').except(:order)                  # discards the order condition
Post.where('id > 10').order('id asc').except(:where) # discards the where condition but keeps the order
# File lib/elasticsearch/persistence/relation/spawn_methods.rb, line 36
def except(*skips)
  relation_with values.except(*skips)
end
merge(other) click to toggle source
# File lib/elasticsearch/persistence/relation/spawn_methods.rb, line 13
def merge(other)
  if other.is_a?(Array)
    to_a & other
  elsif other
    spawn.merge!(other)
  else
    self
  end
end
only(*onlies) click to toggle source

Removes any condition from the query other than the one(s) specified in onlies.

Post.order('id asc').only(:where)         # discards the order condition
Post.order('id asc').only(:where, :order) # uses the specified order
# File lib/elasticsearch/persistence/relation/spawn_methods.rb, line 44
def only(*onlies)
  if onlies.any? { |o| o == :where }
    onlies << :bind
  end
  relation_with values.slice(*onlies)
end
spawn() click to toggle source
# File lib/elasticsearch/persistence/relation/spawn_methods.rb, line 9
def spawn
  clone
end