Sha256: 2535884e6942d465e9367cab200ea934fba59853ff16d7d70f65fe30b056b215

Contents?: true

Size: 714 Bytes

Versions: 4

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true

# @api priavate
# @since 0.5.0
module SmartCore::Container::KeyGuard
  class << self
    # @param key [Symbol, String]
    # @return [void]
    #
    # @raise [SmartCore::Container::ArgumentError]
    #
    # @api private
    # @since 0.5.0
    def prevent_incomparabilities!(key)
      raise(
        SmartCore::Container::ArgumentError,
        'Namespace/Dependency name should be a symbol or a string'
      ) unless key.is_a?(String) || key.is_a?(Symbol)
    end

    # @param key [Symbol, String]
    # @return [String]
    #
    # @api private
    # @since 0.5.0
    def indifferently_accessable_key(key)
      prevent_incomparabilities!(key)
      key.to_s
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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