Module: ResponseFor::ResponsesModule

Includes:
ActionController::ClassMethods
Defined in:
lib/response_for/responses_module.rb

Overview

Extension to facilitate writing responses in mixins

extend this into your own module to have it act as a response_for namespace when this module is included into a controller, the responses will be copied over, along with the actions.

NOTE: If you are defining self.included on your module, make sure you put the extend ResponseFor::ResponsesModule after self.included method definition.

Example:

module MyActions
  extend ResponseFor::ResponsesModule

  def foo
    do_foo
  end

  response_for :foo do |format|
    format.html { # do a response }
  end
end

class AController < ApplicationController
  include MyActions
  # now this controller has foo and response_for :foo
end

Class Method Summary collapse

Methods included from ActionController::ClassMethods

#action_responses, #include_responses_from, #remove_response_for, #response_for

Class Method Details

.extended(mixin) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/response_for/responses_module.rb', line 32

def self.extended(mixin)
  class << mixin
    def included_with_responses(controller_class)
      controller_class.include_responses_from(self)
      included_without_responses(controller_class)
    end
    alias_method_chain :included, :responses
  end
end