Class: ElasticsearchRecord::Relation::QueryClause
- Inherits:
-
Object
- Object
- ElasticsearchRecord::Relation::QueryClause
- Defined in:
- lib/elasticsearch_record/relation/query_clause.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #+(other) ⇒ Object
- #-(other) ⇒ Object
- #ast ⇒ Object
- #hash ⇒ Object
-
#initialize(key, predicates, opts = {}) ⇒ QueryClause
constructor
A new instance of QueryClause.
- #|(other) ⇒ Object
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
#key ⇒ Object (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 |
#ast ⇒ Object
20 21 22 |
# File 'lib/elasticsearch_record/relation/query_clause.rb', line 20 def ast [key, (predicates.one? ? predicates[0] : predicates), opts] end |
#hash ⇒ Object
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 |