Sha256: f33aa72992a54b834b1fc1ee6aee2d7f669f3a0287f847459bbea430c448d486
Contents?: true
Size: 832 Bytes
Versions: 1
Compression:
Stored size: 832 Bytes
Contents
module ROM # @api private class Registry include Enumerable include Equalizer.new(:elements) class ElementNotFoundError < KeyError def initialize(key, name) super("#{key.inspect} doesn't exist in #{name} registry") end end attr_reader :elements, :name def initialize(elements = {}) @elements = elements @name = self.class.name end def each(&block) return to_enum unless block elements.each(&block) end def [](key) elements.fetch(key) { raise ElementNotFoundError.new(key, name) } end def respond_to_missing?(name, include_private = false) key?(name) || super end private def method_missing(name, *args) if elements.key?(name) self[name] else super end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-0.5.0 | lib/rom/support/registry.rb |