Sha256: ffede6c102e003c960861352398cd3bc25b6e52419dbb4691f2fda6884d69cf3
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
# frozen_string_literal: true # @api private # @since 0.8.0 class SmartCore::Container::DependencyResolver::Route require_relative 'route/cursor' # @since 0.8.0 include Enumerable # @return [String] # # @api private # @since 0.8.0 PATH_PART_SEPARATOR = '.' class << self # @param path [String, Symbol] # @return [SmartCore::Container::DependencyResolver::Route] # # @api private # @since 0.8.0 def build(path) new(SmartCore::Container::KeyGuard.indifferently_accessable_key(path)) end # @return [Array<String>] # # @api private # @since 0.8.0 def build_path(*path_parts) path_parts.join(PATH_PART_SEPARATOR) end end # @return [Integer] # # @api private # @since 0.8.0 attr_reader :size # @return [String] # # @api private # @since 0.8.0 attr_reader :path # @param path [String] # @return [void] # # @api private # @since 0.8.0 def initialize(path) @path = path @path_parts = path.split(PATH_PART_SEPARATOR).freeze @size = @path_parts.size end # @param block [Block] # @yield cursor [SmartCore::Container::DependencyResolver::Route::Cursor] # @return [Enumerable] # # @api private # @since 0.8.0 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 private # @return [Array<String>] # # @api private # @since 0.8.0 attr_reader :path_parts end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smart_core-0.8.1 | lib/smart_core/container/dependency_resolver/route.rb |
smart_core-0.8.0 | lib/smart_core/container/dependency_resolver/route.rb |