Class: SearchCriteria::Filter
- Inherits:
-
Object
- Object
- SearchCriteria::Filter
- Defined in:
- lib/domain/search_criteria/model.rb
Overview
Nested Filter class for search criteria filters
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#lower ⇒ Object
Returns the value of attribute lower.
-
#operator ⇒ Object
Returns the value of attribute operator.
-
#upper ⇒ Object
Returns the value of attribute upper.
-
#value ⇒ Object
Returns the value of attribute value.
-
#values ⇒ Object
Returns the value of attribute values.
Class Method Summary collapse
-
.from_json(data) ⇒ Object
Class method to create a Filter from a JSON string.
- .from_site_id(id) ⇒ Object
Instance Method Summary collapse
-
#initialize(field:, operator:, value: nil, values: nil, lower: nil, upper: nil) ⇒ Filter
constructor
A new instance of Filter.
- #to_json(*_options) ⇒ Object
Constructor Details
#initialize(field:, operator:, value: nil, values: nil, lower: nil, upper: nil) ⇒ Filter
Returns a new instance of Filter.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/domain/search_criteria/model.rb', line 17 def initialize( field:, operator:, value: nil, values: nil, lower: nil, upper: nil ) @field = field @operator = operator @value = value @values = values @lower = lower @upper = upper end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
15 16 17 |
# File 'lib/domain/search_criteria/model.rb', line 15 def field @field end |
#lower ⇒ Object
Returns the value of attribute lower.
15 16 17 |
# File 'lib/domain/search_criteria/model.rb', line 15 def lower @lower end |
#operator ⇒ Object
Returns the value of attribute operator.
15 16 17 |
# File 'lib/domain/search_criteria/model.rb', line 15 def operator @operator end |
#upper ⇒ Object
Returns the value of attribute upper.
15 16 17 |
# File 'lib/domain/search_criteria/model.rb', line 15 def upper @upper end |
#value ⇒ Object
Returns the value of attribute value.
15 16 17 |
# File 'lib/domain/search_criteria/model.rb', line 15 def value @value end |
#values ⇒ Object
Returns the value of attribute values.
15 16 17 |
# File 'lib/domain/search_criteria/model.rb', line 15 def values @values end |
Class Method Details
.from_json(data) ⇒ Object
Class method to create a Filter from a JSON string
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/domain/search_criteria/model.rb', line 29 def self.from_json(data) new( field: data['field'], operator: data['operator'], value: data['value'], values: data['values'], lower: data['lower'], upper: data['upper'] ) end |
.from_site_id(id) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/domain/search_criteria/model.rb', line 40 def self.from_site_id(id) new( field: 'site-id', operator: 'in', values: [id] ) end |
Instance Method Details
#to_json(*_options) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/domain/search_criteria/model.rb', line 48 def to_json(*) { field:, operator:, value:, values:, lower:, upper: }.compact end |