Module: ValidationDelegation::ClassMethods
- Defined in:
- lib/validation_delegation.rb
Instance Method Summary collapse
Instance Method Details
#delegate_validation(*args) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/validation_delegation.rb', line 31 def delegate_validation(*args) if args.first.is_a?(Hash) transplant_errors(args.first) else transplant_errors(args.last.merge(attribute: args.first)) end end |
#transplant_errors(options) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/validation_delegation.rb', line 39 def transplant_errors() validate lambda { return unless send([:if]) if [:if] return if send([:unless]) if [:unless] object = send([:to]) ErrorTransplanter.new(self, object, ).transplant unless object.valid? } end |