Class: CampaignHQ::Contact

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#attributesObject (readonly)

Returns the value of attribute attributes.



14
15
16
# File 'lib/campaign_h_q/contact.rb', line 14

def attributes
  @attributes
end

#emailObject (readonly)

Returns the value of attribute email.



14
15
16
# File 'lib/campaign_h_q/contact.rb', line 14

def email
  @email
end

#list_idObject (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

#idObject



32
33
34
# File 'lib/campaign_h_q/contact.rb', line 32

def id
  attributes['id']
end

#saveObject



28
29
30
# File 'lib/campaign_h_q/contact.rb', line 28

def save
  valid? && persist!
end