3
4
5
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
32
33
34
35
36
37
38
|
# File 'lib/helpers/editable.rb', line 3
def self.included base
base.class_eval do
def method_missing method, *args, &block
if editable_data =
method.to_s.match(/editable_([^_]+){0,1}_?(if){0,1}/)
html_tag, check_if = editable_data[1..2]
if check_if
check_result, model_instance, model_field = args
else
model_instance, model_field = args
end
html = (field_value = model_instance.send model_field.to_s)
if block_given?
if check_result
html = capture field_value, check_result, &block
else
html = capture field_value, &block
end
end
debugger
concat(content_tag \
html_tag.to_sym,
html )
else
super method, *args
end
end
end
end
|