Sha256: ba2cc96cfd4280386d96b87fbeccd931470b4c1d8b27ff6d45ea1fc7f899cd38

Contents?: true

Size: 1.52 KB

Versions: 25

Compression:

Stored size: 1.52 KB

Contents

module Merb
  
  module Rack
    
    class Adapter

      class << self
        # Get a rack adapter by id. 
        # ==== Parameters
        # id<String>:: The identifier of the Rack adapter class to retrieve.
        #
        # ==== Returns.
        # Class:: The adapter class.
        #
        # :api: private
        def get(id)
          if @adapters[id.to_s]
            Object.full_const_get(@adapters[id.to_s])
          else
            Merb.fatal! "The adapter #{id} did not exist"
          end
        end

        # Registers a new Rack adapter.
        #
        # ==== Parameters
        # ids<Array>:: Identifiers by which this adapter is recognized by.
        # adapter_class<Class>:: The Rack adapter class.
        #
        # :api: plugin
        def register(ids, adapter_class)
          @adapters ||= Hash.new
          ids.each { |id| @adapters[id] = "Merb::Rack::#{adapter_class}" }
        end
      end # class << self
      
    end # Adapter
    
    # Register some Rack adapters
    Adapter.register %w{ebb},            :Ebb
    Adapter.register %w{emongrel},       :EventedMongrel
    Adapter.register %w{fastcgi fcgi},   :FastCGI
    Adapter.register %w{irb},            :Irb
    Adapter.register %w{mongrel},        :Mongrel  
    Adapter.register %w{runner},         :Runner
    Adapter.register %w{smongrel swift}, :SwiftipliedMongrel
    Adapter.register %w{thin},           :Thin
    Adapter.register %w{thin-turbo tt},  :ThinTurbo
    Adapter.register %w{webrick},        :WEBrick
    
  end # Rack
end # Merb

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
merb-core-1.1.3 lib/merb-core/rack/adapter.rb
merb-core-1.1.2 lib/merb-core/rack/adapter.rb
merb-core-1.1.1 lib/merb-core/rack/adapter.rb
merb-core-1.1.0 lib/merb-core/rack/adapter.rb
merb-core-1.1.0.rc1 lib/merb-core/rack/adapter.rb
merb-core-1.1.0.pre lib/merb-core/rack/adapter.rb
merb-core-1.0.15 lib/merb-core/rack/adapter.rb
merb-core-1.0.14 lib/merb-core/rack/adapter.rb
merb-core-1.0.13 lib/merb-core/rack/adapter.rb
merb-core-1.0.12 lib/merb-core/rack/adapter.rb
merb-core-1.0.10 lib/merb-core/rack/adapter.rb
merb-core-1.0.1 lib/merb-core/rack/adapter.rb
merb-core-1.0.2 lib/merb-core/rack/adapter.rb
merb-core-1.0.11 lib/merb-core/rack/adapter.rb
merb-core-1.0.3 lib/merb-core/rack/adapter.rb
merb-core-1.0.4 lib/merb-core/rack/adapter.rb
merb-core-1.0.5 lib/merb-core/rack/adapter.rb
merb-core-1.0.6.1 lib/merb-core/rack/adapter.rb
merb-core-1.0.8.1 lib/merb-core/rack/adapter.rb
merb-core-1.0.7 lib/merb-core/rack/adapter.rb