Sha256: 24be62a2e1b0c352314a07e373ad57ea3d81cfd9c04bdb3d9af677f2a209be58
Contents?: true
Size: 1.45 KB
Versions: 27
Compression:
Stored size: 1.45 KB
Contents
module Foobara class Namespace class AmbiguousLookupError < StandardError; end class BaseRegistry class WouldMakeRegistryAmbiguousError < StandardError; end class NotRegisteredError < StandardError; end def register(_scoped) # :nocov: raise "Subclass responsibility" # :nocov: end def registered?(path) !lookup(path).nil? end def unregister(_scoped) # :nocov: raise "Subclass responsibility" # :nocov: end def lookup(_path, filter: nil) # :nocov: raise "Subclass responsibility" # :nocov: end # TODO: should return an enumerator def each_scoped(filter: nil, &block) each_scoped_without_filter do |scoped| scoped = apply_filter(scoped, filter) if filter block.call(scoped) if scoped end end def all_scoped(filter: nil) all = [] each_scoped(filter:) do |scoped| all << scoped end all end def each_scoped_without_filter(&) # :nocov: raise "Subclass responsibility" # :nocov: end def apply_filter(object, filter) if filter if object.is_a?(::Array) object.select { |o| o.instance_eval(&filter) } elsif object&.instance_eval(&filter) object end else object end end end end end
Version data entries
27 entries across 27 versions & 1 rubygems