Class: Shared::Collection::TablePresenter
- Inherits:
-
Presenter
- Object
- Presenter
- Shared::Collection::TablePresenter
- Defined in:
- app/presenters/shared/collection/table_presenter.rb
Instance Method Summary collapse
- #actions ⇒ Object
-
#initialize(subject, options = {}) ⇒ TablePresenter
constructor
A new instance of TablePresenter.
- #new_link(options = {}) ⇒ Object
- #set_options(options) ⇒ Object
Constructor Details
#initialize(subject, options = {}) ⇒ TablePresenter
Returns a new instance of TablePresenter.
2 3 4 5 6 7 8 9 10 |
# File 'app/presenters/shared/collection/table_presenter.rb', line 2 def initialize(subject, = {}) super(subject, ) ( { current_parent: parent, show_title: true, append_new_link: true, show_actions: true } ) end |
Instance Method Details
#actions ⇒ Object
16 17 18 19 20 |
# File 'app/presenters/shared/collection/table_presenter.rb', line 16 def actions return content_tag(:td, '') unless show_actions content_tag :td, render('shared/resource/actions', type: type, resource: resource) end |
#new_link(options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/presenters/shared/collection/table_presenter.rb', line 22 def new_link( = {}) return '' unless append_new_link path = if current_parent send( "new_#{root_model_class_name(current_parent).tableize.singularize}_#{type.gsub('.', '_').singularize}_path", current_parent, ) else send("new_#{type.gsub('.', '_').singularize}_path", ) end link_to t("#{type}.new.title"), path end |
#set_options(options) ⇒ Object
12 13 14 |
# File 'app/presenters/shared/collection/table_presenter.rb', line 12 def () @options.merge!() end |