Class: Carnival::Action
- Inherits:
-
Object
- Object
- Carnival::Action
- Defined in:
- app/models/carnival/action.rb
Constant Summary collapse
- PARTIAL_DEFAULT =
"/carnival/shared/action_default"- PARTIAL_DELETE =
"/carnival/shared/action_delete"- PARTIAL_REMOTE =
"/carnival/shared/action_remote"
Instance Method Summary collapse
- #default_partial ⇒ Object
-
#initialize(presenter, name, params = {}) ⇒ Action
constructor
A new instance of Action.
- #name ⇒ Object
- #partial ⇒ Object
- #path(extra_params = {}) ⇒ Object
- #target ⇒ Object
Constructor Details
#initialize(presenter, name, params = {}) ⇒ Action
Returns a new instance of Action.
8 9 10 11 12 13 14 |
# File 'app/models/carnival/action.rb', line 8 def initialize(presenter, name, params={}) @presenter = presenter @name = name @params = params @partial = default_partial @path = params[:path] if params[:path].present? end |
Instance Method Details
#default_partial ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/carnival/action.rb', line 39 def default_partial() if [:new, :edit, :show].include?(@name) PARTIAL_DEFAULT elsif @name == :destroy PARTIAL_DELETE elsif @params[:remote] PARTIAL_REMOTE else PARTIAL_DEFAULT end end |
#name ⇒ Object
31 32 33 |
# File 'app/models/carnival/action.rb', line 31 def name @name end |
#partial ⇒ Object
27 28 29 |
# File 'app/models/carnival/action.rb', line 27 def partial @partial end |
#path(extra_params = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/carnival/action.rb', line 16 def path(extra_params={}) if @path.nil? params = {controller: @presenter.controller_name, action: @name} else params = {path: @path} end params = params.merge(extra_params) if extra_params.present? params = params.merge(:only_path => true) url_for(params) end |
#target ⇒ Object
35 36 37 |
# File 'app/models/carnival/action.rb', line 35 def target @params[:target] end |