Class: Router

Inherits:
Middleman::Extension
  • Object
show all
Defined in:
lib/middleman-router/extension.rb

Overview

Extension namespace

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options_hash = {}, &block) ⇒ Router

Returns a new instance of Router.



19
20
21
22
23
24
# File 'lib/middleman-router/extension.rb', line 19

def initialize(app, options_hash={}, &block)
  super

  @app = app
  require options.routes_location
end

Class Method Details

.add_route(path_name, path_url) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/middleman-router/extension.rb', line 37

def add_route(path_name, path_url)
  puts "#{path_name} => #{path_url}"
  define_singleton_method(path_name) do |*args|
    url(path_url, args.first)
  end

  self.expose_to_template << path_name
end

.draw(&block) ⇒ Object



31
32
33
34
35
# File 'lib/middleman-router/extension.rb', line 31

def draw(&block)
  mapper = Mapper.new(self)
  mapper.instance_exec(&block)
  nil
end

Instance Method Details

#after_configurationObject



26
27
28
# File 'lib/middleman-router/extension.rb', line 26

def after_configuration
  # Do something
end