Class: Caoutsearch::Filter::Base
- Inherits:
-
Object
- Object
- Caoutsearch::Filter::Base
- Defined in:
- lib/caoutsearch/filter/base.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#original_value ⇒ Object
readonly
Returns the value of attribute original_value.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
- #filter ⇒ Object
-
#initialize(key, original_value, type, options = {}) ⇒ Base
constructor
A new instance of Base.
- #value ⇒ Object
Constructor Details
#initialize(key, original_value, type, options = {}) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 17 |
# File 'lib/caoutsearch/filter/base.rb', line 12 def initialize(key, original_value, type, = {}) @key = key @original_value = original_value @type = type @options = end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
6 7 8 |
# File 'lib/caoutsearch/filter/base.rb', line 6 def key @key end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/caoutsearch/filter/base.rb', line 6 def @options end |
#original_value ⇒ Object (readonly)
Returns the value of attribute original_value.
6 7 8 |
# File 'lib/caoutsearch/filter/base.rb', line 6 def original_value @original_value end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/caoutsearch/filter/base.rb', line 6 def type @type end |
Class Method Details
.call ⇒ Object
8 9 10 |
# File 'lib/caoutsearch/filter/base.rb', line 8 def self.call(...) new(...).as_json end |
Instance Method Details
#as_json ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/caoutsearch/filter/base.rb', line 24 def as_json filter = self.filter filter = group_filters(filter) if filter.is_a?(Array) if filter.present? && nested_query? filter = { nested: { path: nested_path, query: {bool: {filter: Array.wrap(filter)}} } } end filter end |
#filter ⇒ Object
40 41 42 |
# File 'lib/caoutsearch/filter/base.rb', line 40 def filter raise NotImplementedError end |
#value ⇒ Object
19 20 21 22 |
# File 'lib/caoutsearch/filter/base.rb', line 19 def value @value = cast_value(original_value) unless defined?(@value) @value end |