Class: Tubular::Builder
- Inherits:
-
Object
- Object
- Tubular::Builder
- Defined in:
- lib/tubular/builder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #column(*args, &block) ⇒ Object
-
#initialize(attributes, &block) ⇒ Builder
constructor
A new instance of Builder.
- #render ⇒ Object
Constructor Details
#initialize(attributes, &block) ⇒ Builder
Returns a new instance of Builder.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/tubular/builder.rb', line 10 def initialize(attributes, &block) @context = attributes.fetch(:context) @collection = attributes.fetch(:collection, []) @table_html = attributes.fetch(:table_html, {}) @columns = [] if block_given? instance_eval(&block) end end |
Class Method Details
.render(*args, &block) ⇒ Object
6 7 8 |
# File 'lib/tubular/builder.rb', line 6 def self.render(*args, &block) new(*args, &block).render end |
Instance Method Details
#column(*args, &block) ⇒ Object
27 28 29 |
# File 'lib/tubular/builder.rb', line 27 def column(*args, &block) columns << build_column(*args, &block) end |
#render ⇒ Object
21 22 23 24 25 |
# File 'lib/tubular/builder.rb', line 21 def render content_tag(:table, table_html) do (render_table_head + render_table_body) if columns.size > 0 end end |