Class: Warped::Filter::Base::Value
- Inherits:
-
Object
- Object
- Warped::Filter::Base::Value
- Defined in:
- lib/warped/api/filter/base/value.rb
Instance Attribute Summary collapse
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Whether the filter is empty.
-
#initialize(filter, relation, value) ⇒ Value
constructor
A new instance of Value.
-
#relation ⇒ String
The validated filter relation.
- #to_h ⇒ Object
-
#value ⇒ String
(also: #html_value)
The casted filter value.
Constructor Details
#initialize(filter, relation, value) ⇒ Value
Returns a new instance of Value.
17 18 19 20 21 |
# File 'lib/warped/api/filter/base/value.rb', line 17 def initialize(filter, relation, value) @filter = filter @relation = relation @value = value end |
Instance Attribute Details
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
10 11 12 |
# File 'lib/warped/api/filter/base/value.rb', line 10 def filter @filter end |
Instance Method Details
#empty? ⇒ Boolean
Returns Whether the filter is empty.
34 35 36 |
# File 'lib/warped/api/filter/base/value.rb', line 34 def empty? value.nil? && !%w[is_null is_not_null].include?(relation) end |
#relation ⇒ String
Returns The validated filter relation.
29 30 31 |
# File 'lib/warped/api/filter/base/value.rb', line 29 def relation filter.relation(@relation) end |
#to_h ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/warped/api/filter/base/value.rb', line 38 def to_h { field: filter.name, relation:, value: } end |
#value ⇒ String Also known as: html_value
Returns The casted filter value.
24 25 26 |
# File 'lib/warped/api/filter/base/value.rb', line 24 def value filter.cast(@value) end |