Module: BelongsToContact
- Defined in:
- lib/contacts/belongs_to_contact.rb
Overview
this module assumes base class has a contact_id attribute. expects base class to respond to :account_name
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#padma_contact ⇒ Object
Returns the value of attribute padma_contact.
Class Method Summary collapse
Instance Method Summary collapse
-
#contact(options = {}) ⇒ PadmaContact / PadmaContactDecorator
Returns associated contact.
Instance Attribute Details
#padma_contact ⇒ Object
Returns the value of attribute padma_contact.
10 11 12 |
# File 'lib/contacts/belongs_to_contact.rb', line 10 def padma_contact @padma_contact end |
Class Method Details
.included(base) ⇒ Object
5 6 7 8 |
# File 'lib/contacts/belongs_to_contact.rb', line 5 def self.included(base) base.send(:validate, :padma_contact_setted_correctly) base.extend ClassMethods end |
Instance Method Details
#contact(options = {}) ⇒ PadmaContact / PadmaContactDecorator
Returns associated contact.
contact is stored in instance variable padma_contact. This allows for it to be setted in a Mass-Load.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/contacts/belongs_to_contact.rb', line 20 def contact(={}) if self.padma_contact.nil? || [:force_service_call] self.padma_contact = PadmaContact.find(contact_id, {select: :all, account_name: self.account_name}) end ret = padma_contact if [:decorated] && padma_contact ret = PadmaContactDecorator.decorate(padma_contact) end ret end |