lib/vedeu/repositories/store.rb in vedeu-0.8.6 vs lib/vedeu/repositories/store.rb in vedeu-0.8.7
- old
+ new
@@ -10,11 +10,15 @@
#
module Store
include Enumerable
include Vedeu::Common
+ include Vedeu::Repositories::Storage
+ alias all storage
+ alias clear reset!
+
# @param block [Proc]
# @return [Enumerator]
def each(&block)
storage.each(&block)
end
@@ -34,11 +38,11 @@
def exists?(name)
return false if empty? || absent?(name)
storage.include?(name)
end
- alias_method :registered?, :exists?
+ alias registered? exists?
# Returns a collection of the names of all the registered
# entities.
#
# @return [Array]
@@ -48,36 +52,15 @@
return storage.to_a if storage.is_a?(Set)
storage
end
- # Remove all currently stored data.
- #
- # @return [Array|Hash|Set]
- def reset!
- Vedeu.log(type: :reset,
- message: "(#{self.class.name}) #{registered.inspect}")
-
- @storage = in_memory
- end
- alias_method :reset, :reset!
- alias_method :clear, :reset
-
# Return the number of entries stored.
#
# @return [Fixnum]
def size
storage.size
end
-
- # Return whole repository; provides raw access to the storage
- # for this repository.
- #
- # @return [Array|Hash|Set]
- def storage
- @storage ||= in_memory
- end
- alias_method :all, :storage
# @return [Hash]
def in_memory
{}
end