Sha256: 49b203633c562f2ff309c19002e9903ba6b7f090039ef46238f563d7fc790b7a

Contents?: true

Size: 720 Bytes

Versions: 10

Compression:

Stored size: 720 Bytes

Contents

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

      def resolve(symbol)
        ensure_initialized!
        @@container.resolve(symbol)
      end

      def resolve_all(symbol)
        ensure_initialized!
        @@container.resolve_all(symbol)
      end

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

      private

      def ensure_initialized!
        raise create_error unless class_variable_defined?(:@@container)
      end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spank-1.1.0 lib/spank/ioc.rb
spank-1.0.1441140881 lib/spank/ioc.rb
spank-1.0.1441140857 lib/spank/ioc.rb
spank-1.0.1441140848 lib/spank/ioc.rb
spank-1.0.1441140841 lib/spank/ioc.rb
spank-1.0.1441140834 lib/spank/ioc.rb
spank-1.0.1441140824 lib/spank/ioc.rb
spank-1.0.1441140809 lib/spank/ioc.rb
spank-1.0.1441140804 lib/spank/ioc.rb
spank-1.0.1441140793 lib/spank/ioc.rb