Module: Faulty::ImmutableOptions
- Included in:
- Cache::AutoWire::Options, Cache::CircuitProxy::Options, Cache::FaultTolerantProxy::Options, Circuit::Options, Options, Status, Storage::AutoWire::Options, Storage::CircuitProxy::Options, Storage::FallbackChain::Options, Storage::FaultTolerantProxy::Options, Storage::Memory::Options, Storage::Redis::Options
- Defined in:
- lib/faulty/immutable_options.rb
Overview
A struct that cannot be modified after initialization
Instance Method Summary collapse
Instance Method Details
#initialize(hash) {|self| ... } ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/faulty/immutable_options.rb', line 8 def initialize(hash) defaults.merge(hash).each { |key, value| self[key] = value } yield self if block_given? finalize required.each do |key| raise ArgumentError, "Missing required attribute #{key}" if self[key].nil? end freeze end |