6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/custom_data.rb', line 6
def reload_custom_data
return unless custom_data
custom_data.each do |data|
define_method(data.method_name) do
custom_data[data.method_name]
end
if data.select?
define_method("#{data.method_name}_humanize") do
data.humanized_option(custom_data[data.method_name])
end
end
define_method("#{data.method_name}=") do |value|
self.custom_data = custom_data.merge(data.method_name => value)
end
next unless data.modal?
define_method(data.normalized_data) do
if send(data.method_name).present?
data.modal_entity.classify.constantize.send(:find, send(data.method_name))
end
end
end
end
|