Sha256: 7bc0c4cf63b5cba0b85994f3f6f6e775a49f5495d61baee4f89a189442f842c4
Contents?: true
Size: 738 Bytes
Versions: 13
Compression:
Stored size: 738 Bytes
Contents
module Mocktail class ValidatesArguments def self.disable! Thread.current[:mocktail_arity_validation_disabled] = true end def self.enable! Thread.current[:mocktail_arity_validation_disabled] = false end def self.disabled? Thread.current[:mocktail_arity_validation_disabled] end def self.optional(disable, &blk) return blk.call unless disable disable! blk.call.tap do enable! end end def initialize @simulates_argument_error = SimulatesArgumentError.new end def validate(dry_call) return if self.class.disabled? if (error = @simulates_argument_error.simulate(dry_call)) raise error end end end end
Version data entries
13 entries across 13 versions & 1 rubygems