Class: TableHelp::TableFor
- Inherits:
-
Object
- Object
- TableHelp::TableFor
- Defined in:
- lib/table_help/table_for.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#column_names ⇒ Object
readonly
Returns the value of attribute column_names.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#strategies ⇒ Object
readonly
Returns the value of attribute strategies.
Instance Method Summary collapse
- #column(name = nil, method_name = nil, &block) ⇒ Object
-
#initialize(collection, context, options = {}) ⇒ TableFor
constructor
A new instance of TableFor.
- #to_html ⇒ Object
Constructor Details
#initialize(collection, context, options = {}) ⇒ TableFor
Returns a new instance of TableFor.
6 7 8 9 10 11 12 |
# File 'lib/table_help/table_for.rb', line 6 def initialize(collection, context, = {}) @collection = collection @context = context @options = .merge() @column_names = [] @strategies = [] end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
3 4 5 |
# File 'lib/table_help/table_for.rb', line 3 def collection @collection end |
#column_names ⇒ Object (readonly)
Returns the value of attribute column_names.
3 4 5 |
# File 'lib/table_help/table_for.rb', line 3 def column_names @column_names end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/table_help/table_for.rb', line 3 def context @context end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/table_help/table_for.rb', line 3 def @options end |
#strategies ⇒ Object (readonly)
Returns the value of attribute strategies.
3 4 5 |
# File 'lib/table_help/table_for.rb', line 3 def strategies @strategies end |
Instance Method Details
#column(name = nil, method_name = nil, &block) ⇒ Object
14 15 16 17 |
# File 'lib/table_help/table_for.rb', line 14 def column(name = nil, method_name = nil, &block) column_names << Formatter.format_attribute_name(name, collection) strategies << Strategy.new(name, block_given? ? block : method_name) end |
#to_html ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/table_help/table_for.rb', line 19 def to_html return if collection.empty? tag.table() do concat thead concat tbody end end |