Method: Sinatra::Namespace.new

Defined in:
lib/sinatra/namespace.rb

.new(base, pattern, conditions = {}, &block) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/sinatra/namespace.rb', line 189

def self.new(base, pattern, conditions = {}, &block)
  Module.new do
    # quelch uninitialized variable warnings, since these get used by compile method.
    @pattern = nil
    @conditions = nil
    extend NamespacedMethods
    include InstanceMethods
    @base = base
    @extensions = []
    @errors = {}
    @pattern, @conditions = compile(pattern, conditions)
    @templates            = Hash.new { |_h, k| @base.templates[k] }
    namespace = self
    before { extend(@namespace = namespace) }
    class_eval(&block)
  end
end