Class: Elasticated::Conditions::RangeCondition
- Inherits:
-
StandardCondition
- Object
- StandardCondition
- Elasticated::Conditions::RangeCondition
- Defined in:
- lib/elasticated/conditions/range_condition.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
example: RangeCondition.new :age, gte: 18, lt: 40.
Attributes inherited from StandardCondition
Instance Method Summary collapse
- #build ⇒ Object
- #fill_delimiter(field_delimiter) ⇒ Object
-
#initialize(field, body, opts = {}) ⇒ RangeCondition
constructor
A new instance of RangeCondition.
Methods included from Mixins::Clonable
Methods included from Mixins::Inspectionable
Constructor Details
#initialize(field, body, opts = {}) ⇒ RangeCondition
Returns a new instance of RangeCondition.
9 10 11 12 |
# File 'lib/elasticated/conditions/range_condition.rb', line 9 def initialize(field, body, opts={}) super(field, opts) self.body = Hash::Indifferent.new body end |
Instance Attribute Details
#body ⇒ Object
example: RangeCondition.new :age, gte: 18, lt: 40
7 8 9 |
# File 'lib/elasticated/conditions/range_condition.rb', line 7 def body @body end |
Instance Method Details
#build ⇒ Object
14 15 16 |
# File 'lib/elasticated/conditions/range_condition.rb', line 14 def build { range: { field => body }.merge(opts) } end |
#fill_delimiter(field_delimiter) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/elasticated/conditions/range_condition.rb', line 18 def fill_delimiter(field_delimiter) minimum_value = body[:gt] || body[:gte] field_delimiter.set_minimum field, minimum_value maximum_value = body[:lt] || body[:lte] field_delimiter.set_maximum field, maximum_value end |