Class: Gaku::ContactUpdation
- Inherits:
-
Object
- Object
- Gaku::ContactUpdation
- Defined in:
- app/services/gaku/contact_updation.rb
Instance Attribute Summary collapse
-
#contact ⇒ Object
readonly
Returns the value of attribute contact.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(contact) ⇒ ContactUpdation
constructor
A new instance of ContactUpdation.
- #update(params) ⇒ Object
Constructor Details
#initialize(contact) ⇒ ContactUpdation
Returns a new instance of ContactUpdation.
5 6 7 8 |
# File 'app/services/gaku/contact_updation.rb', line 5 def initialize(contact) @contact = contact @errors = [] end |
Instance Attribute Details
#contact ⇒ Object (readonly)
Returns the value of attribute contact.
3 4 5 |
# File 'app/services/gaku/contact_updation.rb', line 3 def contact @contact end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
3 4 5 |
# File 'app/services/gaku/contact_updation.rb', line 3 def errors @errors end |
Instance Method Details
#update(params) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/services/gaku/contact_updation.rb', line 10 def update(params) @contact.assign_attributes(params) if @contact.save if @contact.contactable.respond_to?(:contacts) remove_other_primary # update_primary_contact_field end true else @errors = @contact.errors false end end |