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



151
152
153
154
# File 'lib/trafaret/validators.rb', line 151

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

#validate(data) ⇒ Object



156
157
158
# File 'lib/trafaret/validators.rb', line 156

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