Class: Hanami::Routing::Resource::Nested Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/routing/resource/nested.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.

Helper class to calculate nested path

Since:

  • 0.4.0

Constant Summary collapse

SEPARATOR =

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

Since:

  • 0.4.0

'/'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(resource_name, resource) ⇒ Nested

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 Nested.

Since:

  • 0.4.0



15
16
17
18
19
20
# File 'lib/hanami/routing/resource/nested.rb', line 15

def initialize(resource_name, resource)
  @resource_name = resource_name.to_s.split(SEPARATOR)
  @resource      = resource
  @path          = []
  _calculate(@resource_name.dup, @resource)
end

Instance Method Details

#to_pathObject

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.4.0



24
25
26
27
# File 'lib/hanami/routing/resource/nested.rb', line 24

def to_path
  @path.reverse!.pop
  @resource_name.zip(@path).flatten.join
end