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
Returns the value of attribute options.
Instance Method Summary collapse
-
#build_table ⇒ Object
build the complete table with pagination and filters if set.
-
#initialize(table_name, table_me_presenter, options = {}, &block) ⇒ TableForPresenter
constructor
A new instance of TableForPresenter.
Constructor Details
#initialize(table_name, table_me_presenter, options = {}, &block) ⇒ TableForPresenter
Returns a new instance of TableForPresenter.
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/table_me/table_for_presenter.rb', line 74 def initialize table_name, table_me_presenter, = {}, &block @table_me_presenter = table_me_presenter self. = ActiveSupport::HashWithIndifferentAccess.new(.merge(@table_me_presenter.)) self.name = table_name @block = block # required to get capture to work with haml init_haml_helpers if defined?(Haml) setup_classes 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
114 115 116 |
# File 'lib/table_me/table_for_presenter.rb', line 114 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
Returns the value of attribute options.
71 72 73 |
# File 'lib/table_me/table_for_presenter.rb', line 71 def @options end |
Instance Method Details
#build_table ⇒ Object
build the complete table with pagination and filters if set.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/table_me/table_for_presenter.rb', line 90 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 |