Class: Brandmaker::GridVariable
Instance Attribute Summary
Attributes inherited from Variable
#config
Instance Method Summary
collapse
Methods inherited from Variable
#data, #initialize, #label, #purpose, #technical_name, #type_id
Instance Method Details
#actual_values ⇒ Object
25
26
27
28
29
|
# File 'lib/brandmaker/grid_variable.rb', line 25
def actual_values
rows.map do |row|
row.try(:[], :variable).try(:[], :value).presence
end.compact
end
|
#custom_structure ⇒ Object
#custom_structure_values ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/brandmaker/grid_variable.rb', line 31
def custom_structure_values
actual_values.collect do |val|
obj = custom_structure.objects.find do |object|
object[:name] == val
end
obj[:label]
end
end
|
46
47
48
|
# File 'lib/brandmaker/grid_variable.rb', line 46
def val
val.match(/\(([^)]+)\)/).try(:[], 1)
end
|
#rows ⇒ Object
40
41
42
43
44
|
# File 'lib/brandmaker/grid_variable.rb', line 40
def rows
values = @data[:grid][:row]
values = [values] if values.is_a? Hash
values
end
|
#value ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/brandmaker/grid_variable.rb', line 7
def value
begin
if custom_structure.present?
values = custom_structure_values
else
values = actual_values
end
if purpose == VariablePurpose::EMAIL_RECIPIENT
values.map { |val| val }.compact
else
values
end
rescue
super
end
end
|