Sha256: 66727e706a05d1a3704d4b5456b790eedb8c125fe337394d86acddba6c5284d0

Contents?: true

Size: 705 Bytes

Versions: 2

Compression:

Stored size: 705 Bytes

Contents

module InheritedResources
  # 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
  #
  module DSL
    def self.included(base)
      ACTIONS.each do |action|
        base.class_eval <<-WRITTER
          def self.#{action}!(options={}, &block)
            define_method #{action.inspect}!, &block
            class_eval <<-ACTION
              def #{action}
                super(\#{options.inspect}, &method(#{action.inspect}!))
              end
            ACTION
          end
        WRITTER
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
JackDanger-inherited_resources-0.9.1 lib/inherited_resources/dsl.rb
josevalim-inherited_resources-0.9.1 lib/inherited_resources/dsl.rb