Module: Roda::RodaPlugins::HashRoutes::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#freezeObject

Freeze the hash_routes metadata when freezing the app.



269
270
271
272
# File 'lib/roda/plugins/hash_routes.rb', line 269

def freeze
  opts[:hash_routes_methods].freeze
  super
end

#hash_routes(namespace = '', &block) ⇒ Object

Invoke the DSL for configuring hash routes, see DSL for methods inside the block. If the block accepts an argument, yield the DSL instance. If the block does not accept an argument, instance_exec the block in the context of the DSL instance.



278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/roda/plugins/hash_routes.rb', line 278

def hash_routes(namespace='', &block)
  dsl = DSL.new(self, namespace)
  if block
    if block.arity == 1
      yield dsl
    else
      dsl.instance_exec(&block)
    end
  end

  dsl
end