Class: Facades::Builders::TableBuilder
- Inherits:
-
Object
- Object
- Facades::Builders::TableBuilder
- Defined in:
- lib/facades/builders/table.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#resources ⇒ Object
readonly
Returns the value of attribute resources.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #body ⇒ Object
- #head ⇒ Object
-
#headings ⇒ Object
Get a list of all headings for the table Use the resource class’s table_headings method first, options hash next.
-
#initialize(resources, tpl, options) ⇒ TableBuilder
constructor
A new instance of TableBuilder.
-
#inline! ⇒ Object
Renders the table content immediately using the provided options.
-
#resource_class ⇒ Object
The class for this resource.
Constructor Details
#initialize(resources, tpl, options) ⇒ TableBuilder
Returns a new instance of TableBuilder.
6 7 8 9 |
# File 'lib/facades/builders/table.rb', line 6 def initialize(resources, tpl, ) @buffer = "" @template, @options, @resources = tpl, , resources end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
4 5 6 |
# File 'lib/facades/builders/table.rb', line 4 def buffer @buffer end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/facades/builders/table.rb', line 4 def @options end |
#resources ⇒ Object (readonly)
Returns the value of attribute resources.
4 5 6 |
# File 'lib/facades/builders/table.rb', line 4 def resources @resources end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
4 5 6 |
# File 'lib/facades/builders/table.rb', line 4 def template @template end |
Instance Method Details
#body ⇒ Object
41 42 43 44 45 46 |
# File 'lib/facades/builders/table.rb', line 41 def body return content_tag(:tbody, render_body) unless block_given? content_tag(:tbody) do yield self end end |
#head ⇒ Object
34 35 36 37 38 39 |
# File 'lib/facades/builders/table.rb', line 34 def head return content_tag(:thead, render_heading) unless block_given? content_tag(:thead) do yield self end end |
#headings ⇒ Object
Get a list of all headings for the table Use the resource class’s table_headings method first, options hash next
17 18 19 20 |
# File 'lib/facades/builders/table.rb', line 17 def headings return resource_class.table_attributes if resource_class.respond_to?(:table_headings) [[:headings]].flatten.compact end |
#inline! ⇒ Object
Renders the table content immediately using the provided options
30 31 32 |
# File 'lib/facades/builders/table.rb', line 30 def inline! [head, body].map(&:to_s).join("\n") end |
#resource_class ⇒ Object
The class for this resource
24 25 26 |
# File 'lib/facades/builders/table.rb', line 24 def resource_class resources.first.class end |