Class: ValidationDelegation::ErrorTransplanter
- Inherits:
-
Object
- Object
- ValidationDelegation::ErrorTransplanter
- Defined in:
- lib/validation_delegation.rb
Instance Attribute Summary collapse
-
#donor ⇒ Object
Returns the value of attribute donor.
-
#options ⇒ Object
Returns the value of attribute options.
-
#recipient ⇒ Object
Returns the value of attribute recipient.
Instance Method Summary collapse
- #excepted_attribute?(attribute) ⇒ Boolean
- #ignore_attribute?(attribute) ⇒ Boolean
-
#initialize(recipient, donor, options) ⇒ ErrorTransplanter
constructor
A new instance of ErrorTransplanter.
- #specified_attribute?(attribute) ⇒ Boolean
- #transplant ⇒ Object
Constructor Details
#initialize(recipient, donor, options) ⇒ ErrorTransplanter
Returns a new instance of ErrorTransplanter.
56 57 58 59 60 |
# File 'lib/validation_delegation.rb', line 56 def initialize(recipient, donor, ) self.recipient = recipient self.donor = donor self. = end |
Instance Attribute Details
#donor ⇒ Object
Returns the value of attribute donor.
54 55 56 |
# File 'lib/validation_delegation.rb', line 54 def donor @donor end |
#options ⇒ Object
Returns the value of attribute options.
54 55 56 |
# File 'lib/validation_delegation.rb', line 54 def @options end |
#recipient ⇒ Object
Returns the value of attribute recipient.
54 55 56 |
# File 'lib/validation_delegation.rb', line 54 def recipient @recipient end |
Instance Method Details
#excepted_attribute?(attribute) ⇒ Boolean
73 74 75 |
# File 'lib/validation_delegation.rb', line 73 def excepted_attribute?(attribute) Array.wrap([:except]).include?(attribute.to_sym) end |
#ignore_attribute?(attribute) ⇒ Boolean
69 70 71 |
# File 'lib/validation_delegation.rb', line 69 def ignore_attribute?(attribute) excepted_attribute?(attribute) || !specified_attribute?(attribute) end |
#specified_attribute?(attribute) ⇒ Boolean
77 78 79 80 |
# File 'lib/validation_delegation.rb', line 77 def specified_attribute?(attribute) return true unless [:only] Array.wrap([:only]).include?(attribute.to_sym) end |
#transplant ⇒ Object
62 63 64 65 66 67 |
# File 'lib/validation_delegation.rb', line 62 def transplant errors.each do |object_attribute, object_errors| next if ignore_attribute? object_attribute receive_errors [:attribute], object_attribute, object_errors end end |