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

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

Instance Method Summary collapse

Instance Method Details

#freezeObject

Freeze the multi_route regexp matchers so that there can be no thread safety issues at runtime.



95
96
97
98
99
100
101
102
# File 'lib/roda/plugins/multi_route.rb', line 95

def freeze
  super
  opts[:namespaced_routes].each_key do |k|
    self::RodaRequest.named_route_regexp(k)
  end
  self::RodaRequest.instance_variable_get(:@namespaced_route_regexps).freeze
  self
end

#inherited(subclass) ⇒ Object

Copy the named routes into the subclass when inheriting.



105
106
107
108
# File 'lib/roda/plugins/multi_route.rb', line 105

def inherited(subclass)
  super
  subclass::RodaRequest.instance_variable_set(:@namespaced_route_regexps, {})
end

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

Clear the multi_route regexp matcher for the namespace.



111
112
113
114
115
116
# File 'lib/roda/plugins/multi_route.rb', line 111

def route(name=nil, namespace=nil, &block)
  super
  if name
    self::RodaRequest.clear_named_route_regexp!(namespace)
  end
end