Class: RailsTableFor::Elements::Table
- Inherits:
-
Object
- Object
- RailsTableFor::Elements::Table
- Includes:
- ActionView::Helpers::TagHelper, Helpers::Paginate
- Defined in:
- lib/rails_table_for/elements/table.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
writeonly
Sets the attribute columns.
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
-
#page_size ⇒ Object
writeonly
Sets the attribute page_size.
-
#record_count ⇒ Object
writeonly
Sets the attribute record_count.
-
#records ⇒ Object
writeonly
Sets the attribute records.
-
#request_params ⇒ Object
writeonly
Sets the attribute request_params.
-
#request_path ⇒ Object
writeonly
Sets the attribute request_path.
Instance Method Summary collapse
- #column(field = nil, **options, &block) ⇒ Object
-
#initialize(records, **options) ⇒ Table
constructor
A new instance of Table.
- #to_s ⇒ Object
Constructor Details
#initialize(records, **options) ⇒ Table
Returns a new instance of Table.
17 18 19 20 21 22 23 24 25 |
# File 'lib/rails_table_for/elements/table.rb', line 17 def initialize(records, **) @records = records @record_count = records.count @columns = [] [:columns]&.each { |field| column(field) } @page_size = [:page_size] @request_path = [:request_path] @request_params = [:request_params] end |
Instance Attribute Details
#columns=(value) ⇒ Object
Sets the attribute columns
13 14 15 |
# File 'lib/rails_table_for/elements/table.rb', line 13 def columns=(value) @columns = value end |
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
13 14 15 |
# File 'lib/rails_table_for/elements/table.rb', line 13 def output_buffer @output_buffer end |
#page_size=(value) ⇒ Object
Sets the attribute page_size
13 14 15 |
# File 'lib/rails_table_for/elements/table.rb', line 13 def page_size=(value) @page_size = value end |
#record_count=(value) ⇒ Object
Sets the attribute record_count
13 14 15 |
# File 'lib/rails_table_for/elements/table.rb', line 13 def record_count=(value) @record_count = value end |
#records=(value) ⇒ Object
Sets the attribute records
13 14 15 |
# File 'lib/rails_table_for/elements/table.rb', line 13 def records=(value) @records = value end |
#request_params=(value) ⇒ Object
Sets the attribute request_params
13 14 15 |
# File 'lib/rails_table_for/elements/table.rb', line 13 def request_params=(value) @request_params = value end |
#request_path=(value) ⇒ Object
Sets the attribute request_path
13 14 15 |
# File 'lib/rails_table_for/elements/table.rb', line 13 def request_path=(value) @request_path = value end |
Instance Method Details
#column(field = nil, **options, &block) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/rails_table_for/elements/table.rb', line 27 def column(field = nil, **, &block) if block_given? columns << BlockColumn.new(block, ) elsif field columns << FieldColumn.new(field, ) else raise 'Must provide either field or block' end end |
#to_s ⇒ Object
37 38 39 40 41 42 |
# File 'lib/rails_table_for/elements/table.rb', line 37 def to_s return '' if record_count.zero? return '' if columns.empty? draw end |