Sha256: e4319797923ac27b4c22dda8edb190bf0ff2e03203478078873b9aab9f2eb5db

Contents?: true

Size: 520 Bytes

Versions: 2

Compression:

Stored size: 520 Bytes

Contents

module Spank
  class IOC
    class << self
      def bind_to(container)
        @@container = container
      end

      def resolve(symbol)
        raise create_error unless class_variable_defined?(:@@container)
        @@container.resolve(symbol)
      end

      def unbind
        remove_class_variable(:@@container) if class_variable_defined?(:@@container)
      end

      private

      def create_error
        ContainerError.new("Spank::IOC.bind_to(container) has not been called.")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spank-1.0.1420314444 lib/spank/ioc.rb
spank-0.0.1393558686 lib/spank/ioc.rb