Sha256: a7e6058d3585304327e9531b3ec8bfd761d8764b15bf941346092da5e3af07c0

Contents?: true

Size: 638 Bytes

Versions: 6

Compression:

Stored size: 638 Bytes

Contents

class SmartIoC::ExtraPackageContexts
  def initialize
    @data = {}
  end

  # @param package_name [Symbol]
  # @param context [Symbol]
  def set_context(package_name, context)
    if !package_name.is_a?(Symbol)
      raise ArgumentError, "package name should be a Symbol"
    end

    if !context.is_a?(Symbol)
      raise ArgumentError, "context should be a Symbol"
    end

    @data[package_name] = context
  end

  def get_context(package_name)
    @data[package_name] || SmartIoC::Container::DEFAULT_CONTEXT
  end

  # @param package_name [Symbol]
  def clear_context(package_name)
    @data.delete(package_name)
    nil
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
smart_ioc-0.1.19 lib/smart_ioc/extra_package_contexts.rb
smart_ioc-0.1.18 lib/smart_ioc/extra_package_contexts.rb
smart_ioc-0.1.17 lib/smart_ioc/extra_package_contexts.rb
smart_ioc-0.1.16 lib/smart_ioc/extra_package_contexts.rb
smart_ioc-0.1.14 lib/smart_ioc/extra_package_contexts.rb
smart_ioc-0.1.13 lib/smart_ioc/extra_package_contexts.rb