Sha256: 2cd8ed21aa65861e4a22f2715c20b0595a7ab9ad0134fbb091120274cef6be2c

Contents?: true

Size: 623 Bytes

Versions: 4

Compression:

Stored size: 623 Bytes

Contents

require "omnicontacts"

module OmniContacts
  class Builder < Rack::Builder
    def initialize(app,&block)
      if rack14?
        super
      else
        @app = app
        super(&block)
      end
    end

    def rack14?
      Rack.release.split('.')[1].to_i >= 4
    end

    def importer importer, *args
      middleware = OmniContacts::Importer.const_get(importer.to_s.capitalize)
      use middleware, *args
    rescue NameError
      raise LoadError, "Could not find importer #{importer}."
    end

    def call env
      @ins << @app unless rack14? || @ins.include?(@app)
      to_app.call(env)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
omnicontacts-0.1.5 lib/omnicontacts/builder.rb
omnicontacts-0.1.4 lib/omnicontacts/builder.rb
omnicontacts-0.1.3 lib/omnicontacts/builder.rb
omnicontacts-0.1.2 lib/omnicontacts/builder.rb