class LB::Project::Registry

Basic key value store

Attributes

keys[R]

Public Class Methods

new(keys = {}) click to toggle source
# File lib/lb/project/registry.rb, line 19
def initialize(keys = {})
  @keys = keys
end

Public Instance Methods

[](key)
Alias for: fetch
each() { |key, value| ... } click to toggle source
# File lib/lb/project/registry.rb, line 23
def each(&block)
  return to_enum unless block
  keys.each_pair { |key, value| yield(key, value) }
end
fetch(key) { || ... } click to toggle source
# File lib/lb/project/registry.rb, line 32
def fetch(key)
  raise ArgumentError, 'key cannot be nil' if key.nil?

  keys.fetch(key.to_sym) do
    return yield if block_given?

    raise KeyNotFoundError, key
  end
end
Also aliased as: []
key?(key) click to toggle source
# File lib/lb/project/registry.rb, line 28
def key?(key)
  !key.nil? && keys.key?(key.to_sym)
end
register(key, value) click to toggle source
# File lib/lb/project/registry.rb, line 47
def register(key, value)
  keys[key] = value
end
respond_to_missing?(key, include_private = false) click to toggle source
Calls superclass method
# File lib/lb/project/registry.rb, line 43
def respond_to_missing?(key, include_private = false)
  keys.key?(key) || super
end

Private Instance Methods

method_missing(key, *) click to toggle source
Calls superclass method
# File lib/lb/project/registry.rb, line 53
def method_missing(key, *)
  keys.fetch(key) { super }
end