public
Description: response for lets you decorate your actions respond_to blocks
Homepage: http://blog.ardes.com/response_for
Clone URL: git://github.com/ianwhite/response_for.git
Click here to lend your support to: response_for and make a donation at www.pledgie.com !
response_for / lib / ardes / responses_module.rb
100644 42 lines (41 sloc) 1.18 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
module Ardes#:nodoc:
  # 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 Ardes::ResponsesModule *after* self.included method definition.
  #
  # Example:
  #
  # module MyActions
  # extend Ardes::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
  module ResponsesModule
    include ResponseFor::ClassMethods
    
    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
  end
end