Class: Sinatra::Hat::Router

Inherits:
Object show all
Defined in:
lib/sinatras-hat/router.rb

Overview

Tells Sinatra which routes to generate. The routes created automatically when the actions are loaded.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(maker) ⇒ Router

Returns a new instance of Router.



14
15
16
# File 'lib/sinatras-hat/router.rb', line 14

def initialize(maker)
  @maker = maker
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



8
9
10
# File 'lib/sinatras-hat/router.rb', line 8

def app
  @app
end

#makerObject (readonly)

Returns the value of attribute maker.



8
9
10
# File 'lib/sinatras-hat/router.rb', line 8

def maker
  @maker
end

Class Method Details

.cacheObject



10
11
12
# File 'lib/sinatras-hat/router.rb', line 10

def self.cache
  @cache ||= []
end

Instance Method Details

#generate(app) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/sinatras-hat/router.rb', line 18

def generate(app)
  @app = app
  
  Router.cache.each do |route|
    map(*route)
  end
end