Class: Para::Plugins::Routes

Inherits:
Object
  • Object
show all
Defined in:
lib/para/plugins/routes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(router) ⇒ Routes

Returns a new instance of Routes.



6
7
8
# File 'lib/para/plugins/routes.rb', line 6

def initialize(router)
  @router = router
end

Instance Attribute Details

#routerObject (readonly)

Returns the value of attribute router.



4
5
6
# File 'lib/para/plugins/routes.rb', line 4

def router
  @router
end

Instance Method Details

#plugin(identifier, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/para/plugins/routes.rb', line 10

def plugin(identifier, &block)
  # Store router reference in closure to allow accessing it from
  # inside the below block
  router = self.router

  router.instance_eval do
    scope module: [:para, identifier].join('/').to_sym do
      router.instance_eval(&block)
    end
  end
end