Class: CustomAudience::CustomAudience

Inherits:
Object
  • Object
show all
Defined in:
lib/custom_audience.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_or_hash = {}) ⇒ CustomAudience

Returns a new instance of CustomAudience.



12
13
14
15
16
17
18
19
20
21
# File 'lib/custom_audience.rb', line 12

def initialize(name_or_hash = {})
  if name_or_hash.is_a?(Hash)
    @attributes = name_or_hash.stringify_keys
  else
    @attributes = {"name" => name_or_hash}
  end

  self.token = @attributes.delete('token')
  fetch_attributes!
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



10
11
12
# File 'lib/custom_audience.rb', line 10

def attributes
  @attributes
end

#tokenObject

Returns the value of attribute token.



10
11
12
# File 'lib/custom_audience.rb', line 10

def token
  @token
end

#usersObject

Returns the value of attribute users.



9
10
11
# File 'lib/custom_audience.rb', line 9

def users
  @users
end

Instance Method Details

#account_idObject



44
45
46
# File 'lib/custom_audience.rb', line 44

def 
  attributes['account_id'].to_s.gsub(/^act_/, '')
end

#account_id=(account_id) ⇒ Object



34
35
36
37
# File 'lib/custom_audience.rb', line 34

def ()
  attributes["account_id"] = 
  fetch_attributes!
end

#exists?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/custom_audience.rb', line 23

def exists?
  id.present?
end

#idObject



52
53
54
# File 'lib/custom_audience.rb', line 52

def id
  attributes["id"]
end

#nameObject



48
49
50
# File 'lib/custom_audience.rb', line 48

def name
  attributes["name"]
end

#saveObject



27
28
29
30
31
32
# File 'lib/custom_audience.rb', line 27

def save
  # Should try and fetch attributes?
  create if ! exists?

  add_users
end