Sha256: 97125e7f60dea902f97c1d8fff1f9414eb6c0102add648287aa7045c3e389a44
Contents?: true
Size: 808 Bytes
Versions: 1
Compression:
Stored size: 808 Bytes
Contents
class Chaos::Injection ATTRIBUTES = %i(target method_name instability_type instability_arguments probability execute_if).freeze attr_accessor *ATTRIBUTES attr_reader :instability_factory private :instability_factory def initialize(instability_factory: Chaos::InstabilityFactory.new) @instability_factory = instability_factory end def validate! ATTRIBUTES.each do |attribute| present?(public_send(attribute)) or raise ":#{attribute} is not set!" end end def instability instability_factory.build(instability_type) end def execute_if @execute_if || ->(_arg) { true } end def execute_if=(val) raise "is not a lambda-like object" if !val.respond_to?(:call) @execute_if = val end private def present?(value) !value.nil? end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chaos-rb-0.1.0 | lib/chaos/injection.rb |