Class: Elasticated::Delimiters::DateFieldDelimiter
- Inherits:
-
TermFieldDelimiter
- Object
- StandardFieldDelimiter
- TermFieldDelimiter
- Elasticated::Delimiters::DateFieldDelimiter
- Defined in:
- lib/elasticated/delimiters/date_field_delimiter.rb
Instance Attribute Summary collapse
-
#date_since ⇒ Object
Returns the value of attribute date_since.
-
#date_until ⇒ Object
Returns the value of attribute date_until.
Attributes inherited from TermFieldDelimiter
Attributes inherited from StandardFieldDelimiter
Instance Method Summary collapse
- #build_strategy_params ⇒ Object
- #set_maximum(field, date) ⇒ Object
- #set_minimum(field, date) ⇒ Object
Methods inherited from TermFieldDelimiter
Methods inherited from StandardFieldDelimiter
#add_term, #applies_to?, #initialize
Constructor Details
This class inherits a constructor from Elasticated::Delimiters::TermFieldDelimiter
Instance Attribute Details
#date_since ⇒ Object
Returns the value of attribute date_since.
5 6 7 |
# File 'lib/elasticated/delimiters/date_field_delimiter.rb', line 5 def date_since @date_since end |
#date_until ⇒ Object
Returns the value of attribute date_until.
5 6 7 |
# File 'lib/elasticated/delimiters/date_field_delimiter.rb', line 5 def date_until @date_until end |
Instance Method Details
#build_strategy_params ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/elasticated/delimiters/date_field_delimiter.rb', line 19 def build_strategy_params params = Hash.new if values.empty? raise "date_since is higher than date_until (#{date_since} - #{date_until})" \ if date_since && date_until && date_since > date_until params.merge! date_since: date_since if date_since params.merge! date_until: date_until if date_until else raise "Only one 'term' filter is allowed over the '#{field_name}' field" if values.count > 1 params.merge! date: values.first end params end |
#set_maximum(field, date) ⇒ Object
13 14 15 16 17 |
# File 'lib/elasticated/delimiters/date_field_delimiter.rb', line 13 def set_maximum(field, date) return unless applies_to? field return if is_now?(date) self.date_until = date unless date_until && date > date_until end |
#set_minimum(field, date) ⇒ Object
7 8 9 10 11 |
# File 'lib/elasticated/delimiters/date_field_delimiter.rb', line 7 def set_minimum(field, date) return unless applies_to? field raise("The date 'now' is not valid as minimum value of a range condition") if is_now?(date) self.date_since = date unless date_since && date < date_since end |