lib/spank/ioc.rb in spank-0.0.1385937112 vs lib/spank/ioc.rb in spank-0.0.1393558686
- old
+ new
@@ -1,11 +1,24 @@
module Spank
class IOC
- def self.bind_to(container)
- @@container = container
- end
+ class << self
+ def bind_to(container)
+ @@container = container
+ end
- def self.resolve(symbol)
- @@container.resolve(symbol)
+ 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