Sha256: 6740a2bb92057cfc65050cc9d3136ff00afbf15188b5fd81c66776a9b2a52eb3

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

# @api private
# @since 0.5.0
module SmartCore::Container::DependencyBuilder
  class << self
    # @param external_name [String]
    # @param dependency_definition [Proc]
    # @option memoize [Boolean]
    # @return [SmartCore::Container::Dependency, SmartCore::Container::MemoizedDependency]
    #
    # @api private
    # @since 0.5.0
    def build(external_name, dependency_definition, memoize: false, **options)
      # @todo: raise an error if memoize is not a boolean

      if memoize
        build_memoized_dependency(external_name, dependency_definition, **options)
      else
        build_dependency(external_name, dependency_definition, **options)
      end
    end

    private

    # @param external_name [String]
    # @param dependency_definition [Proc]
    # @param options [Hash<Symbol,Any>]
    # @return [SmartCore::Container::MemoizedDependency]
    #
    # @api private
    # @since 0.5.0
    def build_memoized_dependency(external_name, dependency_definition, **options)
      SmartCore::Container::MemoizedDependency.new(external_name, dependency_definition, **options)
    end

    # @param external_name [String]
    # @param dependency_definition [Proc]
    # @param options [Hash<Symbol,Any>]
    # @return [SmartCore::Container::Dependency]
    #
    # @api private
    # @since 0.5.0
    def build_dependency(external_name, dependency_definition, **options)
      SmartCore::Container::Dependency.new(external_name, dependency_definition, **options)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smart_core-0.6.0 lib/smart_core/container/dependency_builder.rb
smart_core-0.5.2 lib/smart_core/container/dependency_builder.rb
smart_core-0.5.1 lib/smart_core/container/dependency_builder.rb
smart_core-0.5.0 lib/smart_core/container/dependency_builder.rb