Class: TwitterBootstrapBuilder::Builders::TableBuilder

Inherits:
Base
  • Object
show all
Defined in:
lib/twitter_bootstrap_builder/builders/table_builder.rb

Instance Attribute Summary

Attributes inherited from Base

#block, #options, #template

Instance Method Summary collapse

Methods inherited from Base

#html_safe

Constructor Details

#initialize(*args, &block) ⇒ TableBuilder

Returns a new instance of TableBuilder.



5
6
7
8
# File 'lib/twitter_bootstrap_builder/builders/table_builder.rb', line 5

def initialize(*args, &block)
  super
  @fields = {}
end

Instance Method Details

#actions(&block) ⇒ Object



37
38
39
40
# File 'lib/twitter_bootstrap_builder/builders/table_builder.rb', line 37

def actions(&block)
  @actions_block = block
  nil
end

#collectionObject



24
25
26
# File 'lib/twitter_bootstrap_builder/builders/table_builder.rb', line 24

def collection
  options[:collection]
end

#field(method, &block) ⇒ Object



32
33
34
35
# File 'lib/twitter_bootstrap_builder/builders/table_builder.rb', line 32

def field(method, &block)
  @fields[method] = block
  nil
end

#model_classObject



28
29
30
# File 'lib/twitter_bootstrap_builder/builders/table_builder.rb', line 28

def model_class
  options[:model_class] || collection.klass
end

#to_sObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/twitter_bootstrap_builder/builders/table_builder.rb', line 10

def to_s
  template.capture(self, &block) if block

  Tag.block(:div, class: 'table-container') do |data|
    data.append do |d|
      Tag.block(:table, class: 'table table-striped table-condensed') do |table|
        table.append thead
        table.append tbody
      end
    end
    data.append pager
  end.html_safe
end