Class: DisplayFor::Builder::List
Instance Attribute Summary
#collection
Attributes inherited from Base
#html_options, #namespace, #resource_class, #template
Instance Method Summary
collapse
#default_actions, #initialize
Methods inherited from Base
#action, #attribute, #html, #initialize
Instance Method Details
#build_actions(resource) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/display_for/builder/list.rb', line 17
def build_actions(resource)
result = []
@actions.each do |action|
result << action.content(resource)
end
result.join(" ").html_safe
end
|
#build_row(resource) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/display_for/builder/list.rb', line 5
def build_row(resource)
result = ''
@attributes.each do |attribute|
result << content_tag(:span, attribute.content(resource), attribute.html_options)
end
result << content_tag(:span, build_actions(resource)) if @actions.any?
options = {}
options[:id] = "#{@resource_class}_#{resource.id}".underscore if resource
content_tag(:li, result.html_safe, options) << "\n"
end
|
42
43
44
45
|
# File 'lib/display_for/builder/list.rb', line 42
def
@footer = List.new(resource_class, [], html_options, template)
yield @footer
end
|
#to_s ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/display_for/builder/list.rb', line 27
def to_s
result = "\n".html_safe
@collection.each do |resource|
result << build_row(resource)
end
if @footer
result << @footer.build_row(nil)
end
html_options[:class] ||= "list #{@resource_class.to_s.underscore}-list"
content_tag(:ul, result, html_options).html_safe
end
|