Class: Trafaret::Proc

Inherits:
Validator show all
Defined in:
lib/trafaret/validators.rb

Instance Attribute Summary

Attributes inherited from Validator

#converters, #options

Instance Method Summary collapse

Methods inherited from Validator

#&, #===, #add, #call, #convert, #failure, #initialize, #perform_convert, #to, #|

Constructor Details

This class inherits a constructor from Trafaret::Validator

Instance Method Details

#prepareObject



164
165
166
167
# File 'lib/trafaret/validators.rb', line 164

def prepare
  raise 'Need to call with block' if @converters.blank?
  @blk = @converters.pop
end

#validate(data) ⇒ Object



169
170
171
# File 'lib/trafaret/validators.rb', line 169

def validate(data)
  @blk.call(data)
end