Sha256: 76e4dcc09d776f5a0a8ca9086f89e9b3434ec22b70d928ab252e599ce3bbb1b5

Contents?: true

Size: 978 Bytes

Versions: 1

Compression:

Stored size: 978 Bytes

Contents

require 'rack/amf/middleware'

module Rack::AMF::Middleware #:nodoc:
  class Rails
    include Rack::AMF::Middleware

    def initialize app, options={}
      @app = app

      options.delete(:url) # Too late to modify the URL
      Rack::AMF::Environment.populate options
    end

    def handle env
      @app.call env
    end

    def self.install_environment
      return if @installed
      @installed = true

      # Load in files
      extras_dir = File.dirname(__FILE__)+'/../rails'
      Dir["#{extras_dir}/*.rb"].each {|f| require f}

      # Install route
      ActionController::Routing::RouteSet.class_eval do
        next if self.instance_methods.include? 'draw_with_rackamf'
        def draw_with_rackamf
          draw_without_rackamf do |map|
            map.rack_amf Rack::AMF::Environment.url, :controller => 'rack_amf', :action => 'handle'
            yield map
          end
        end
        alias_method_chain :draw, :rackamf
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-amf-0.0.3 lib/rack/amf/middleware/rails.rb