Module: Sinatra::Hat::Extendor

Included in:
Maker
Defined in:
lib/sinatras-hat/extendor.rb

Overview

This module gives both Sinatra::Base and Sinatra::Hat::Maker the #mount method, which is used to mount resources. When mount is called in an instance of Maker, it sets the new instance’s parent.

Instance Method Summary collapse

Instance Method Details

#mount(klass, options = {}, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sinatras-hat/extendor.rb', line 8

def mount(klass, options={}, &block)
  unless kind_of?(Sinatra::Hat::Maker)
    use Rack::MethodOverride 
  end
  
  Maker.new(klass, options).tap do |maker|
    maker.parent = self if kind_of?(Sinatra::Hat::Maker)
    maker.setup(@app || self)
    maker.instance_eval(&block) if block_given?
    maker.generate_routes!
  end
end