Class: TableHelp::AttributesTableFor
- Inherits:
-
Object
- Object
- TableHelp::AttributesTableFor
- Defined in:
- lib/table_help/attributes_table_for.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
-
#initialize(resource, context, options = {}) ⇒ AttributesTableFor
constructor
A new instance of AttributesTableFor.
- #row(name = nil, method_name = nil, &block) ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(resource, context, options = {}) ⇒ AttributesTableFor
Returns a new instance of AttributesTableFor.
6 7 8 9 10 11 |
# File 'lib/table_help/attributes_table_for.rb', line 6 def initialize(resource, context, = {}) @resource = resource @context = context = .merge() @rows = [] end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/table_help/attributes_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/attributes_table_for.rb', line 3 def end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
3 4 5 |
# File 'lib/table_help/attributes_table_for.rb', line 3 def resource @resource end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
3 4 5 |
# File 'lib/table_help/attributes_table_for.rb', line 3 def rows @rows end |
Instance Method Details
#row(name = nil, method_name = nil, &block) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/table_help/attributes_table_for.rb', line 13 def row(name = nil, method_name = nil, &block) rows << [ Formatter.format_attribute_name(name, resource), Strategy.new(name, block_given? ? block : method_name), ] end |
#to_html ⇒ Object
20 21 22 23 |
# File 'lib/table_help/attributes_table_for.rb', line 20 def to_html return if resource.nil? tag.table(tbody, ) end |