Sha256: a316fdbcf9645392a29b3689648d2bebdcb42aa62b9369dfb099599f85ab5cc0
Contents?: true
Size: 756 Bytes
Versions: 1
Compression:
Stored size: 756 Bytes
Contents
require 'singleton' require 'ez/registry/store' require 'ez/registry/record' module Ez class Registry include Singleton class << self def in(key, by:, &block) get_or_initialize_store_by(key) add!(yield(Registry::Store.new), to: store[key], by: by) end def store(key = nil) @store ||= {} if key @store[key] || Registry::Store.new else @store end end private def get_or_initialize_store_by(key) store[key] || store[key] = Registry::Store.new end def add!(*collection, to: , by:) collection.flatten.each do |record| record.by = by to.push(record) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ez-core-0.1.0 | lib/ez/registry.rb |