Class: CampaignHQ::Contact
- Inherits:
-
Object
- Object
- CampaignHQ::Contact
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion, ActiveModel::Validations
- Defined in:
- lib/campaign_h_q/contact.rb
Overview
Contact of a list
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#list_id ⇒ Object
readonly
Returns the value of attribute list_id.
Class Method Summary collapse
Instance Method Summary collapse
- #id ⇒ Object
-
#initialize(list_id, params = {}) ⇒ Contact
constructor
A new instance of Contact.
- #save ⇒ Object
Constructor Details
#initialize(list_id, params = {}) ⇒ Contact
Returns a new instance of Contact.
18 19 20 21 22 |
# File 'lib/campaign_h_q/contact.rb', line 18 def initialize(list_id, params = {}) @list_id = list_id @attributes = params @email = @attributes[:email] end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
14 15 16 |
# File 'lib/campaign_h_q/contact.rb', line 14 def attributes @attributes end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
14 15 16 |
# File 'lib/campaign_h_q/contact.rb', line 14 def email @email end |
#list_id ⇒ Object (readonly)
Returns the value of attribute list_id.
14 15 16 |
# File 'lib/campaign_h_q/contact.rb', line 14 def list_id @list_id end |
Class Method Details
.create(list_id, params = {}) ⇒ Object
24 25 26 |
# File 'lib/campaign_h_q/contact.rb', line 24 def self.create(list_id, params = {}) new(list_id, params).tap(&:save) end |
Instance Method Details
#id ⇒ Object
32 33 34 |
# File 'lib/campaign_h_q/contact.rb', line 32 def id attributes['id'] end |
#save ⇒ Object
28 29 30 |
# File 'lib/campaign_h_q/contact.rb', line 28 def save valid? && persist! end |