Class: SimpleDataPresentation::SimpleTable::Base
- Inherits:
-
Object
- Object
- SimpleDataPresentation::SimpleTable::Base
- Defined in:
- lib/simple_data_presentation/simple_table/base.rb
Instance Method Summary collapse
-
#initialize(context, collection, options = {}, &content_block) ⇒ Base
constructor
A new instance of Base.
- #item(*args, &block) ⇒ Object
- #render! ⇒ Object
- #title(*args, &block) ⇒ Object
- #value(*args, &block) ⇒ Object
Constructor Details
#initialize(context, collection, options = {}, &content_block) ⇒ Base
Returns a new instance of Base.
2 3 4 5 6 7 8 9 10 |
# File 'lib/simple_data_presentation/simple_table/base.rb', line 2 def initialize(context, collection, = {}, &content_block) @context = context @collection = collection @options = @content_block = content_block @resource_class = @options.delete(:resource_class) || @collection.first.class @html_options = SimpleDataPresentation::HtmlOptions.new(@options.delete(:html) || {}) @html_options[:class] = "table" end |
Instance Method Details
#item(*args, &block) ⇒ Object
12 13 14 |
# File 'lib/simple_data_presentation/simple_table/base.rb', line 12 def item(*args, &block) self.title(*args.clone) || self.value(*args.clone, &block) end |
#render! ⇒ Object
24 25 26 27 28 |
# File 'lib/simple_data_presentation/simple_table/base.rb', line 24 def render! thead = SimpleDataPresentation::SimpleTable::Head.new @context, @resource_class, @options.clone, &@content_block tbody = SimpleDataPresentation::SimpleTable::Body.new @context, @collection, @options.clone, &@content_block @context.raw @context.content_tag :table, thead.render! + tbody.render!, @html_options end |
#title(*args, &block) ⇒ Object
16 17 18 |
# File 'lib/simple_data_presentation/simple_table/base.rb', line 16 def title(*args, &block) nil end |
#value(*args, &block) ⇒ Object
20 21 22 |
# File 'lib/simple_data_presentation/simple_table/base.rb', line 20 def value(*args, &block) nil end |