Class: SmartCore::Container::DependencyResolver::Route Private

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/smart_core/container/dependency_resolver/route.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.

Since:

  • 0.1.0

Version:

  • 0.4.0

Defined Under Namespace

Classes: Cursor

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ void

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.

Parameters:

  • path (String)

Since:

  • 0.1.0

Version:

  • 0.4.0



50
51
52
53
54
# File 'lib/smart_core/container/dependency_resolver/route.rb', line 50

def initialize(path)
  @path = path
  @path_parts = path.split(SmartCore::Container::DependencyResolver::PATH_PART_SEPARATOR).freeze
  @size = @path_parts.size
end

Instance Attribute Details

#pathString (readonly)

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:

  • (String)

Since:

  • 0.1.0



42
43
44
# File 'lib/smart_core/container/dependency_resolver/route.rb', line 42

def path
  @path
end

#sizeInteger (readonly)

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:

  • (Integer)

Since:

  • 0.1.0



36
37
38
# File 'lib/smart_core/container/dependency_resolver/route.rb', line 36

def size
  @size
end

Class Method Details

.build(path) ⇒ SmartCore::Container::DependencyResolver::Route

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.

Parameters:

  • path (String, Symbol)

Returns:

Since:

  • 0.1.0



18
19
20
# File 'lib/smart_core/container/dependency_resolver/route.rb', line 18

def build(path)
  new(SmartCore::Container::KeyGuard.indifferently_accessable_key(path))
end

.build_path(*path_parts) ⇒ Array<String>

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:

  • (Array<String>)

Since:

  • 0.1.0

Version:

  • 0.4.0



27
28
29
# File 'lib/smart_core/container/dependency_resolver/route.rb', line 27

def build_path(*path_parts)
  path_parts.join(SmartCore::Container::DependencyResolver::PATH_PART_SEPARATOR)
end

Instance Method Details

#each(&block) ⇒ Enumerable

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.

Parameters:

  • block (Block)

Returns:

  • (Enumerable)

Since:

  • 0.1.0



62
63
64
65
66
67
68
69
70
71
# File 'lib/smart_core/container/dependency_resolver/route.rb', line 62

def each(&block)
  enumerator = Enumerator.new do |yielder|
    path_parts.each_with_index do |path_part, path_part_index|
      cursor = Cursor.new(path_part, path_part_index, self)
      yielder.yield(cursor)
    end
  end

  block_given? ? enumerator.each(&block) : enumerator
end