module Verifier
Defines {#verify} method to check variables
@example
class Greeter include Verifier def hello(name) verify(:name, :long_enough) { count > 1 } "Hello, #{ name }!" end end greeter = Greeter.new greeter.hello "Ali" # => "Hello, Ali!" greeter.hello "X" # => <Verifier::Invalid ...>
Exceptions raised by Verifier#verify
method
Constants
- Invalid
Exception raised when a verification fails
- MethodFails
Exception raised when calling a verified method raises a StandardError
- MethodNotDefined
Exception raised when a verified method is not defined
- VERSION
The semantic version of the module. @see semver.org/ Semantic versioning 2.0
Public Instance Methods
verify(method, name, &block)
click to toggle source
Runs a verification
@param [Symbol] method
the name of the method to be verified
@param [Symbol] name
the name of verification
@param [Proc] block
@yield block in the scope of a value returned by the method
@raise [Verifier::MethodNotDefined]
if the method not defined
@raise [Verifier::MethodFails]
it calling the method raises a +StandardError+
@raise [Verifier::Invalid]
if the block fails or returns a value whose negation is truthy
@return [undefined]
@api public
# File lib/verifier.rb, line 48 def verify(method, name, &block) Verification.run(self, method, name, &block) end