Method: PassthruValidator#target_instance
- Defined in:
- app/validators/passthru_validator.rb
#target_instance(record) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'app/validators/passthru_validator.rb', line 91 def target_instance(record) instance_attributes = if [:with].respond_to?(:call) [:with].call(record) else [:with] || {} end instance_attributes.each do |key, val| instance_attributes[key] = val.call(record) if val.respond_to?(:call) end target_class.new(instance_attributes) end |