Module Resourceful::Maker
In: lib/resourceful/maker.rb

This module is extended by the ActionController::Base class object. It provides the actual make_resourceful method and sets up the controller so that everything will work.

Methods

Public Class methods

Called automatically on ActionController::Base. Initializes various inheritable attributes.

[Source]

    # File lib/resourceful/maker.rb, line 11
11:     def self.extended(base)
12:       base.write_inheritable_attribute :resourceful_callbacks, {}
13:       base.write_inheritable_attribute :resourceful_responses, {}
14:       base.write_inheritable_attribute :parents,               []
15:     end

Public Instance methods

This is the central method, and namesake, of make_resourceful. It takes a block and evaluates it in the context of a Builder, allowing the controller to be customized extensively.

See Resourceful::Builder for documentation on the methods available in the context of the block.

The only option currently available is :include. It takes an object that responds to to_proc (or an array of such objects) and evaluates that proc in the same context as the block. For example:

  make_resourceful :include => proc { actions :all } do
    before :show do
      current_object.current_user = current_user
    end
  end

This is the same as:

  make_resourceful do
    actions :all
    before :show do
      current_object.current_user = current_user
    end
  end

[Source]

    # File lib/resourceful/maker.rb, line 48
48:     def make_resourceful(options = {}, &block)
49:       # :stopdoc:
50:       include Resourceful::Base
51:       # :startdoc:
52: 
53:       builder = Resourceful::Builder.new(self)
54:       (Resourceful::Base.made_resourceful + Array(options[:include])).each { |proc| builder.instance_eval(&proc) }
55:       builder.instance_eval(&block)
56: 
57:       builder.apply
58: 
59:       add_helpers
60:     end

[Validate]