Class: TableCloth::Builder
- Inherits:
-
Object
- Object
- TableCloth::Builder
- Defined in:
- lib/table_cloth/builder.rb
Instance Attribute Summary collapse
-
#presenter ⇒ Object
Returns the value of attribute presenter.
-
#table ⇒ Object
Returns the value of attribute table.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#presenter ⇒ Object
Returns the value of attribute presenter.
3 4 5 |
# File 'lib/table_cloth/builder.rb', line 3 def presenter @presenter end |
#table ⇒ Object
Returns the value of attribute table.
3 4 5 |
# File 'lib/table_cloth/builder.rb', line 3 def table @table end |
Class Method Details
.build(objects, view, options = {}, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/table_cloth/builder.rb', line 5 def self.build(objects, view, ={}, &block) if block_given? table = Class.new(TableCloth::Base) block.call(table) else table_class = .delete(:with) table = table_class.kind_of?(String) ? table_class.constantize : table_class end presenter = .delete(:present_with) || table.presenter new.tap do |builder| builder.table = table builder.presenter = presenter.new(objects, table, view) end end |
Instance Method Details
#to_s ⇒ Object
22 23 24 |
# File 'lib/table_cloth/builder.rb', line 22 def to_s presenter.render_table end |