Class: ElasticsearchRecord::Relation::QueryClause

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticsearch_record/relation/query_clause.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, predicates, opts = {}) ⇒ QueryClause

Returns a new instance of QueryClause.



10
11
12
13
14
# File 'lib/elasticsearch_record/relation/query_clause.rb', line 10

def initialize(key, predicates, opts = {})
  @key       = key
  @predicates = predicates
  @opts       = opts
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



8
9
10
# File 'lib/elasticsearch_record/relation/query_clause.rb', line 8

def key
  @key
end

Instance Method Details

#+(other) ⇒ Object



24
25
26
# File 'lib/elasticsearch_record/relation/query_clause.rb', line 24

def +(other)
  ::ElasticsearchRecord::Relation::QueryClause.new(key, predicates + other.predicates, opts.merge(other.opts))
end

#-(other) ⇒ Object



28
29
30
# File 'lib/elasticsearch_record/relation/query_clause.rb', line 28

def -(other)
  ::ElasticsearchRecord::Relation::QueryClause.new(key, predicates - other.predicates, Hash[opts.to_a - other.opts.to_a])
end

#astObject



20
21
22
# File 'lib/elasticsearch_record/relation/query_clause.rb', line 20

def ast
  [key, (predicates.one? ? predicates[0] : predicates), opts]
end

#hashObject



16
17
18
# File 'lib/elasticsearch_record/relation/query_clause.rb', line 16

def hash
  [self.class, key, predicates, opts].hash
end

#|(other) ⇒ Object



32
33
34
# File 'lib/elasticsearch_record/relation/query_clause.rb', line 32

def |(other)
  ::ElasticsearchRecord::Relation::QueryClause.new(key, predicates | other.predicates, Hash[opts.to_a | other.opts.to_a])
end