Class: RSchema::PredicateSchema

Inherits:
Struct
  • Object
show all
Defined in:
lib/rschema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#blockObject

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



199
200
201
# File 'lib/rschema.rb', line 199

def block
  @block
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



199
200
201
# File 'lib/rschema.rb', line 199

def name
  @name
end

Instance Method Details

#schema_walk(value, mapper) ⇒ Object



200
201
202
203
204
205
206
# File 'lib/rschema.rb', line 200

def schema_walk(value, mapper)
  if block.call(value)
    value
  else
    RSchema::ErrorDetails.new(value, 'fails predicate' + (name ? ": #{name}" : ''))
  end
end