12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/garnish/converter.rb', line 12
def convert(record, view = nil)
view ||= self.template
if record.respond_to?(:each)
klass = record.first.class
else
klass = record.class
end
presenter_name = "#{klass.to_s}Presenter"
if module_exists?(presenter_name.to_sym)
if record.respond_to?(:each)
record.map do |v|
v.extend(presenter_name.constantize)
v.template = view
end
else
record.extend(presenter_name.constantize)
record.template = view
end
end
end
|