Class: ActiveSet::Filtering::Enumerable::SetInstruction
Instance Method Summary
collapse
#attribute_value_for, #case_insensitive_operation_for?, #initialize, #instruction_value
Instance Method Details
#attribute_class ⇒ Object
36
37
38
|
# File 'lib/active_set/filtering/enumerable/set_instruction.rb', line 36
def attribute_class
attribute_instance&.class
end
|
#attribute_instance ⇒ Object
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/active_set/filtering/enumerable/set_instruction.rb', line 25
def attribute_instance
return set_item if @attribute_instruction.associations_array.empty?
return @attribute_model if defined? @attribute_model
@attribute_model = @attribute_instruction
.associations_array
.reduce(set_item) do |obj, assoc|
obj.public_send(assoc)
end
end
|
#item_matches_query?(item) ⇒ Boolean
11
12
13
14
15
16
17
|
# File 'lib/active_set/filtering/enumerable/set_instruction.rb', line 11
def item_matches_query?(item)
return query_result_for(item, query_attribute_for(instruction_value)) unless operator_hash.key?(:reducer)
Array.wrap(instruction_value).public_send(operator_hash[:reducer]) do |value|
query_result_for(item, query_attribute_for(value))
end
end
|
#set_item ⇒ Object
19
20
21
22
23
|
# File 'lib/active_set/filtering/enumerable/set_instruction.rb', line 19
def set_item
return @set_item if defined? @set_item
@set_item = @set.find(&:present?)
end
|