Sha256: 3a035ab1baff7416fb98b1ba7aae3c1fffb0e2c61fc3ff35a70b709e3cb4f96f
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
module Carnival class Action include Rails.application.routes.url_helpers PARTIAL_DEFAULT = "/carnival/shared/action_default" PARTIAL_DELETE = "/carnival/shared/action_delete" PARTIAL_REMOTE = "/carnival/shared/action_remote" def initialize(presenter, name, params={}) @presenter = presenter @name = name @params = params @partial = default_partial @path = params[:path] if params[:path].present? end def path(extra_params={}) if @path.nil? params = {controller: @presenter.controller_name, action: @name} params = params.merge(extra_params) if extra_params.present? params = params.merge(:only_path => true) url_for(params) else @path end end def partial @partial end def name @name end def target @params[:target] end 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
carnival-0.0.11 | app/models/carnival/action.rb |
carnival-0.0.10 | app/models/carnival/action.rb |