Class: PackAPI::Querying::AttributeFilter
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#filter_name, filter_name, #type
Constructor Details
Returns a new instance of AttributeFilter.
19
20
21
22
|
# File 'lib/pack_api/querying/attribute_filter.rb', line 19
def initialize(value)
super()
@value = value
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
5
6
7
|
# File 'lib/pack_api/querying/attribute_filter.rb', line 5
def value
@value
end
|
Class Method Details
.data_type ⇒ Object
11
12
13
|
# File 'lib/pack_api/querying/attribute_filter.rb', line 11
def self.data_type
raise NotImplementedError
end
|
.definition ⇒ Object
15
16
17
|
# File 'lib/pack_api/querying/attribute_filter.rb', line 15
def self.definition(**)
PackAPI::Types::SimpleFilterDefinition.new(name: filter_name, data_type:)
end
|
.type ⇒ Object
7
8
9
|
# File 'lib/pack_api/querying/attribute_filter.rb', line 7
def self.type
:attribute
end
|
Instance Method Details
#apply_to(query) ⇒ Object
32
33
34
|
# File 'lib/pack_api/querying/attribute_filter.rb', line 32
def apply_to(query)
query.add(query.build.where(to_h))
end
|
#present? ⇒ Boolean
24
25
26
|
# File 'lib/pack_api/querying/attribute_filter.rb', line 24
def present?
!value.nil?
end
|
#to_h ⇒ Object
28
29
30
|
# File 'lib/pack_api/querying/attribute_filter.rb', line 28
def to_h
{ filter_name => value }
end
|