Module: InheritedResources::DSL

Defined in:
lib/inherited_resources/dsl.rb

Overview

Allows controllers to write actions using a class method DSL.

class MyController < InheritedResources::Base
  create! do |success, failure|
    success.html { render :text => "It works!" }
  end
end

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/inherited_resources/dsl.rb', line 11

def self.included(base)
  ACTIONS.each do |action|
    base.class_eval "def self.\#{action}!(options={}, &block)\ndefine_method :__\#{action}, &block\nclass_eval <<-ACTION\ndef \#{action}\nsuper(\\\#{options.inspect}, &method(:__\#{action}))\nend\nACTION\nend\n"
  end
end