Class: BCDD::Value::Registry

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/bcdd/ext/value.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRegistry

Returns a new instance of Registry.



112
113
114
# File 'lib/bcdd/ext/value.rb', line 112

def initialize
  @registry = {}
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



110
111
112
# File 'lib/bcdd/ext/value.rb', line 110

def registry
  @registry
end

Class Method Details

.read(name) ⇒ Object



124
125
126
127
128
# File 'lib/bcdd/ext/value.rb', line 124

def self.read(name)
  value_object = instance.registry[name]

  value_object or raise ArgumentError, "#{name.inspect} is not registered"
end

.write(options) ⇒ Object



116
117
118
119
120
121
122
# File 'lib/bcdd/ext/value.rb', line 116

def self.write(options)
  name = options.delete(:name)

  name.is_a?(Symbol) or raise ArgumentError, "#{name.inspect} must be a Symbol"

  instance.registry[name] = Value.new(**options)
end