Sha256: e991a17e9135b9b78e22c4080625ec6bc0afdbd300af06ac69bcb30369f317d5

Contents?: true

Size: 864 Bytes

Versions: 69

Compression:

Stored size: 864 Bytes

Contents

module Middleman::CoreExtensions::RackMap
  class << self
    def registered(app)
      app.extend ClassMethods
    end
    alias :included :registered
  end
  
  module ClassMethods
    def map(path, &block)
      @maps ||= []
      @maps << [path, block]
    end
  
    def maps
      @maps || []
    end
  
    # Creates a Rack::Builder instance with all the middleware set up and
    # an instance of this class as end point.
    def build(*args, &bk)
      builder = ::Rack::Builder.new
      builder.use ::Sinatra::ShowExceptions       if show_exceptions?
      builder.use ::Rack::CommonLogger   if logging?
      builder.use ::Rack::Head
      middleware.each { |c,a,b| builder.use(c, *a, &b) }
      maps.each { |p,b| builder.map(p, &b) }
      app = self
      builder.map "/" do
        run app.new!(*args, &bk)
      end
      builder
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
middleman-2.0.14.pre lib/middleman/core_extensions/rack_map.rb
middleman-2.0.13.1-x86-mingw32 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.13.1 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.13-x86-mingw32 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.13 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.12-x86-mingw32 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.12 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.12.pre-x86-mingw32 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.12.pre lib/middleman/core_extensions/rack_map.rb
middleman-2.0.11 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.11-x86-mingw32 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.11.pre-x86-mingw32 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.11.pre lib/middleman/core_extensions/rack_map.rb
middleman-2.0.10-x86-mingw32 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.10 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.9-x86-mingw32 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.9 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.9.pre.3-x86-mingw32 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.9.pre.3 lib/middleman/core_extensions/rack_map.rb
middleman-2.0.9.pre.2-x86-mingw32 lib/middleman/core_extensions/rack_map.rb