Class: Hanami::Routing::Namespace Private

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/hanami/routing/namespace.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Namespace for routes. Implementation of Hanami::Router#namespace

See Also:

Since:

  • 0.1.0

Instance Method Summary collapse

Constructor Details

#initialize(router, name, &blk) ⇒ Namespace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Namespace.

Since:

  • 0.1.0


17
18
19
20
21
22
# File 'lib/hanami/routing/namespace.rb', line 17

def initialize(router, name, &blk)
  @router = router
  @name   = Utils::PathPrefix.new(name)
  __setobj__(@router)
  instance_eval(&blk)
end

Instance Method Details

#delete(path, options = {}, &endpoint) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


50
51
52
# File 'lib/hanami/routing/namespace.rb', line 50

def delete(path, options = {}, &endpoint)
  super(@name.join(path), options, &endpoint)
end

#get(path, options = {}, &endpoint) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


26
27
28
# File 'lib/hanami/routing/namespace.rb', line 26

def get(path, options = {}, &endpoint)
  super(@name.join(path), options, &endpoint)
end

#mount(app, options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.1.0


86
87
88
# File 'lib/hanami/routing/namespace.rb', line 86

def mount(app, options)
  super(app, options.merge(at: @name.join(options[:at])))
end

#namespace(name, &blk) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Supports nested namespaces

Since:

  • 0.1.0


93
94
95
# File 'lib/hanami/routing/namespace.rb', line 93

def namespace(name, &blk)
  Routing::Namespace.new(self, name, &blk)
end

#options(path, options = {}, &endpoint) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


62
63
64
# File 'lib/hanami/routing/namespace.rb', line 62

def options(path, options = {}, &endpoint)
  super(@name.join(path), options, &endpoint)
end

#patch(path, options = {}, &endpoint) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


44
45
46
# File 'lib/hanami/routing/namespace.rb', line 44

def patch(path, options = {}, &endpoint)
  super(@name.join(path), options, &endpoint)
end

#post(path, options = {}, &endpoint) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


32
33
34
# File 'lib/hanami/routing/namespace.rb', line 32

def post(path, options = {}, &endpoint)
  super(@name.join(path), options, &endpoint)
end

#put(path, options = {}, &endpoint) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


38
39
40
# File 'lib/hanami/routing/namespace.rb', line 38

def put(path, options = {}, &endpoint)
  super(@name.join(path), options, &endpoint)
end

#redirect(path, options = {}, &endpoint) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


80
81
82
# File 'lib/hanami/routing/namespace.rb', line 80

def redirect(path, options = {}, &endpoint)
  super(@name.join(path), options.merge(to: @name.join(options[:to])), &endpoint)
end

#resource(name, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


68
69
70
# File 'lib/hanami/routing/namespace.rb', line 68

def resource(name, options = {})
  super name, options.merge(namespace: @name.relative_join(options[:namespace]))
end

#resources(name, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


74
75
76
# File 'lib/hanami/routing/namespace.rb', line 74

def resources(name, options = {})
  super name, options.merge(namespace: @name.relative_join(options[:namespace]))
end

#trace(path, options = {}, &endpoint) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0


56
57
58
# File 'lib/hanami/routing/namespace.rb', line 56

def trace(path, options = {}, &endpoint)
  super(@name.join(path), options, &endpoint)
end