class Contracts::Builtin::Send
Takes a variable number of method names as symbols. Given an argument, all of those methods are called on the argument one by one. If they all return true, the contract passes. Example: Send[:valid?]
Public Class Methods
new(*meths)
click to toggle source
# File lib/contracts/builtin_contracts.rb, line 186 def initialize(*meths) @meths = meths end
Public Instance Methods
to_s()
click to toggle source
# File lib/contracts/builtin_contracts.rb, line 196 def to_s "a value that returns true for all of #{@meths.inspect}" end
valid?(val)
click to toggle source
# File lib/contracts/builtin_contracts.rb, line 190 def valid?(val) @meths.all? do |meth| val.send(meth) end end