Class: Contracts::Constraints::Predicate

Inherits:
Base
  • Object
show all
Defined in:
lib/contracts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#to_h

Constructor Details

#initialize(description, &block) ⇒ Predicate

Returns a new instance of Predicate.



224
225
226
227
# File 'lib/contracts.rb', line 224

def initialize(description, &block)
  (@description = description
   @block = block)
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



230
231
232
# File 'lib/contracts.rb', line 230

def description
  @description
end

Instance Method Details

#matches?(value) ⇒ Boolean

Returns:

  • (Boolean)


229
# File 'lib/contracts.rb', line 229

def matches?(value) = @block.call(value)