Sha256: 8ed6b27393b802c26c33e2b46d07e66be07e7a3ed35e66c5092158ac3a247cc1

Contents?: true

Size: 624 Bytes

Versions: 16

Compression:

Stored size: 624 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

16 entries across 16 versions & 1 rubygems

Version Path
omnicontacts-0.3.7 lib/omnicontacts/builder.rb
omnicontacts-0.3.6 lib/omnicontacts/builder.rb
omnicontacts-0.3.5 lib/omnicontacts/builder.rb
omnicontacts-0.3.4 lib/omnicontacts/builder.rb
omnicontacts-0.3.3 lib/omnicontacts/builder.rb
omnicontacts-0.3.2 lib/omnicontacts/builder.rb
omnicontacts-0.3.1 lib/omnicontacts/builder.rb
omnicontacts-0.3.0 lib/omnicontacts/builder.rb
omnicontacts-0.2.5 lib/omnicontacts/builder.rb
omnicontacts-0.2.4 lib/omnicontacts/builder.rb
omnicontacts-0.2.3 lib/omnicontacts/builder.rb
omnicontacts-0.2.2 lib/omnicontacts/builder.rb
omnicontacts-0.2.1 lib/omnicontacts/builder.rb
omnicontacts-0.2.0 lib/omnicontacts/builder.rb
omnicontacts-0.1.7 lib/omnicontacts/builder.rb
omnicontacts-0.1.6 lib/omnicontacts/builder.rb