Class: ActiveSet::EnumerableSetInstruction
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- ActiveSet::EnumerableSetInstruction
show all
- Defined in:
- lib/active_set/enumerable_set_instruction.rb
Instance Method Summary
collapse
Constructor Details
Returns a new instance of EnumerableSetInstruction.
5
6
7
8
9
|
# File 'lib/active_set/enumerable_set_instruction.rb', line 5
def initialize(attribute_instruction, set)
@attribute_instruction = attribute_instruction
@set = set
super(@attribute_instruction)
end
|
Instance Method Details
#attribute_value_for(item) ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/active_set/enumerable_set_instruction.rb', line 11
def attribute_value_for(item)
@item_values ||= Hash.new do |h, key|
item_value = @attribute_instruction.value_for(item: key)
item_value = item_value.downcase if case_insensitive_operation_for?(item_value)
h[key] = item_value
end
@item_values[item]
end
|
#case_insensitive_operation_for?(value) ⇒ Boolean
29
30
31
32
33
|
# File 'lib/active_set/enumerable_set_instruction.rb', line 29
def case_insensitive_operation_for?(value)
return false unless @attribute_instruction.case_insensitive?
value.is_a?(String) || value.is_a?(Symbol)
end
|
#instruction_value ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/active_set/enumerable_set_instruction.rb', line 21
def instruction_value
return @instruction_value if defined? @instruction_value
instruction_value = @attribute_instruction.value
instruction_value = instruction_value.downcase if case_insensitive_operation_for?(instruction_value)
@instruction_value = instruction_value
end
|