Class: QueryFilter::Rules::Range

Inherits:
Scope
  • Object
show all
Defined in:
lib/query_filter/rules/range.rb

Constant Summary

Constants inherited from Scope

Scope::VALIDATON_KEYS

Instance Attribute Summary

Attributes inherited from Scope

#keys

Instance Method Summary collapse

Methods inherited from Scope

#blank_validation?, #can_apply?, #endpoint, #key

Constructor Details

#initialize(keys, options = {}) ⇒ Range

Returns a new instance of Range.



8
9
10
11
# File 'lib/query_filter/rules/range.rb', line 8

def initialize(keys, options = {})
  @key = Array(keys).first
  super([key_from, key_to], options)
end

Instance Method Details

#nameObject



13
14
15
# File 'lib/query_filter/rules/range.rb', line 13

def name
  'range'
end

#normalize_params(values) ⇒ Object



22
23
24
# File 'lib/query_filter/rules/range.rb', line 22

def normalize_params(values)
  build_range_from_params(values)
end

#valid?(values) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/query_filter/rules/range.rb', line 17

def valid?(values)
  filter = build_range_from_params(values)
  filter.valid?
end