Module: Roda::RodaPlugins::MultiRoute::ClassMethods

Defined in:
lib/roda/plugins/multi_route.rb

Instance Method Summary collapse

Instance Method Details

#inherited(subclass) ⇒ Object

Copy the named routes into the subclass when inheriting.



62
63
64
65
# File 'lib/roda/plugins/multi_route.rb', line 62

def inherited(subclass)
  super
  subclass.instance_variable_set(:@named_routes, @named_routes.dup)
end

#named_route(name) ⇒ Object

Return the named route with the given name.



73
74
75
# File 'lib/roda/plugins/multi_route.rb', line 73

def named_route(name)
  @named_routes[name]
end

#named_routesObject

The names for the currently stored named routes



68
69
70
# File 'lib/roda/plugins/multi_route.rb', line 68

def named_routes
  @named_routes.keys
end

#route(name = nil, &block) ⇒ Object

If the given route has a name, treat it as a named route and store the route block. Otherwise, this is the main route, so call super.



80
81
82
83
84
85
86
87
# File 'lib/roda/plugins/multi_route.rb', line 80

def route(name=nil, &block)
  if name
    @named_routes[name] = block
    self::RodaRequest.clear_named_route_regexp!
  else
    super(&block)
  end
end