Module: MimeActor::Action

Extended by:
ActiveSupport::Concern
Includes:
AbstractController::Rendering, ActionController::MimeResponds, Logging, Scene, Stage
Defined in:
lib/mime_actor/action.rb

Overview

# MimeActor Action

‘Action` is the recommended `Module` to be included in the `ActionController`.

Provides intuitive way of ‘action` processing for a specific MIME type with callback + rescue handlers.

Constant Summary

Constants included from Callbacks

Callbacks::LIFECYCLES

Instance Method Summary collapse

Methods included from Stage

#cue_actor

Methods included from Rescue

#rescue_actor

Methods included from Callbacks

#run_act_callbacks

Instance Method Details

#start_scene(&block) ⇒ Object

The core logic where rendering logics are collected as ‘Proc` and passed over to `ActionController::MimeResponds`

Examples:

process ‘create` action

# it uses AbstractController#action_name to process
start_scene { create_internal }

# it is equivalent to the following if `create` action is configured with `html` and `json` formats
def create
  respond_to |format|
    format.html { create_internal }
    format.json { create_internal }
  end
end


47
48
49
50
51
52
53
54
55
56
57
# File 'lib/mime_actor/action.rb', line 47

def start_scene(&block)
  action = action_name.to_sym
  formats = acting_scenes.fetch(action, {})

  if formats.empty?
    logger.warn { "no format found for action: #{action_name.inspect}" }
    yield if block_given?
  else
    respond_to_scene(action, formats, block)
  end
end