lib/r10k/registry.rb in r10k-1.2.4 vs lib/r10k/registry.rb in r10k-1.3.0rc1
- old
+ new
@@ -1,32 +1,4 @@
-module R10K
+require 'r10k/instance_cache'
- # R10K::Registry implements a generic object memoization container. It caches
- # new objects and returns cached objects based on the instantiation arguments.
- class Registry
-
- # Initialize a new registry with a given class
- #
- # @param klass [Class] The class to memoize
- # @param method [Symbol] The method name to use when creating objects.
- # Defaults to :new.
- def initialize(klass, method = :new)
- @klass = klass
- @method = method
- @instances = {}
- end
-
- # Create a new object, or return a memoized object.
- #
- # @param args [*Object] The arguments to pass to the initialize method
- #
- # @return [Object] A memoized instance of the registered class
- def generate(*args)
- @instances[args] ||= @klass.send(@method, *args)
- end
-
- # Clear all memoized objects
- def clear!
- @instances = {}
- end
- end
-end
+# @deprecated
+R10K::Registry = R10K::InstanceCache