Method: Faulty.register
- Defined in:
- lib/faulty.rb
.register(name, instance = nil, **config) {|Faulty::Options| ... } ⇒ Faulty?
Register an instance to the global Faulty state
Will not replace an existing instance with the same name. Check the return value if you need to know whether the instance already existed.
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/faulty.rb', line 87 def register(name, instance = nil, **config, &block) raise UninitializedError unless @instances if instance raise ArgumentError, 'Do not give config options if an instance is given' if !config.empty? || block else instance = new(**config, &block) end @instances.put_if_absent(name.to_s, instance) end |