Sha256: 317448f7fc2d58cbaedeb4a45ea41d554b56d309b44323941b5446a4885aa03c

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

require 'rack'
require 'amf'
require 'rack/amf/environment'

module Rack::AMF
  def self.new app, options={} #:nodoc:
    # Set default mode
    options[:mode] = :service_manager if !options[:mode]

    # Which version of the middleware?
    if options[:mode] == :pass_through
      require 'rack/amf/middleware/pass_through'
      Middleware::PassThrough.new(app, options)
    elsif options[:mode] == :service_manager
      require 'rack/amf/middleware/service_manager'
      Middleware::ServiceManager.new(app, options)
    else
      raise "Invalide mode: #{options[:mode]}"
    end
  end
end
=begin
require 'rack'
require 'amf'
require 'rack/amf/environment'

# Rack::AMF middleware
module Rack::AMF; end;

# Bootstrap based on environment
if defined?(Rails)
  # Load in needed files
  require 'rack/amf/middleware/rails'

  #--
  # Then we'll modify new to return the middleware to use in rails
  module Rack::AMF
    def self.new app, options={} #:nodoc:
      Middleware::Rails.new(app, options)
    end
  end

  # Set default configs
  Rack::AMF::Environment.url = '/amf'
  Rack::AMF::Environment.mode = :rails

  # Install rails mods
  Rack::AMF::Middleware::Rails.install_environment
else
  module Rack::AMF
    def self.new app, options={} #:nodoc:
      # Set default mode
      options[:mode] = :service_manager if !options[:mode]

      # Which version of the middleware?
      if options[:mode] == :pass_through
        require 'rack/amf/middleware/pass_through'
        Middleware::PassThrough.new(app, options)
      elsif options[:mode] == :service_manager
        require 'rack/amf/middleware/service_manager'
        Middleware::ServiceManager.new(app, options)
      else
        raise "Invalide mode: #{options[:mode]}"
      end
    end
  end
end
=end

Version data entries

1 entries across 1 versions & 1 rubygems

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