Class: TableMe::TableForPresenter
- Inherits:
-
ActionView::Base
- Object
- ActionView::Base
- TableMe::TableForPresenter
- Includes:
- ActionView::Helpers::CaptureHelper, Haml::Helpers
- Defined in:
- lib/table_me/table_for_presenter.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
get data from the table_me_presenter in the controller.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
same as data above, only with table options.
Instance Method Summary collapse
-
#build_table ⇒ Object
build the complete table with pagination and filters if set.
-
#initialize(table_name, options = {}, &block) ⇒ TableForPresenter
constructor
A new instance of TableForPresenter.
Constructor Details
#initialize(table_name, options = {}, &block) ⇒ TableForPresenter
Returns a new instance of TableForPresenter.
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/table_me/table_for_presenter.rb', line 74 def initialize table_name, = {}, &block # self.parent = parent self. = self.name = table_name @block = block # required to get capture to work with haml init_haml_helpers if defined?(Haml) process_data_attributes end |
Instance Attribute Details
#data ⇒ Object (readonly)
get data from the table_me_presenter in the controller. This breaks encapsulation and makes this class too tightly coupled to the TableMePresenter, I wanted to keep the table data out of the class variables in the controller and view, but there has to be a better way to do it. TODO decouple this and options below
112 113 114 |
# File 'lib/table_me/table_for_presenter.rb', line 112 def data @data end |
#name ⇒ Object
Returns the value of attribute name.
71 72 73 |
# File 'lib/table_me/table_for_presenter.rb', line 71 def name @name end |
#options ⇒ Object
same as data above, only with table options. Ideally this needs to be a value object instead of just a hash. TODO use a value object instead of a hash, see table_vo.rb
119 120 121 |
# File 'lib/table_me/table_for_presenter.rb', line 119 def @options end |
Instance Method Details
#build_table ⇒ Object
build the complete table with pagination and filters if set.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/table_me/table_for_presenter.rb', line 88 def build_table <<-HTML.strip_heredoc.html_safe <div class='table-me'> #{table_filters} <div class="table-me-table #{'with-filters' if table_builder.filters}"> #{table_pagination.pagination_info} <table> <thead> <tr>#{create_header}</tr> </thead> <tbody> #{table_rows} </tbody> </table> #{table_pagination.pagination_controls} </div> </div> HTML end |