Class: CustomAudience::CustomAudience
- Inherits:
-
Object
- Object
- CustomAudience::CustomAudience
- Defined in:
- lib/custom_audience.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#token ⇒ Object
Returns the value of attribute token.
-
#users ⇒ Object
Returns the value of attribute users.
Instance Method Summary collapse
- #account_id ⇒ Object
- #account_id=(account_id) ⇒ Object
- #exists? ⇒ Boolean
- #id ⇒ Object
-
#initialize(name_or_hash = {}) ⇒ CustomAudience
constructor
A new instance of CustomAudience.
- #name ⇒ Object
- #save ⇒ Object
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
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
10 11 12 |
# File 'lib/custom_audience.rb', line 10 def attributes @attributes end |
#token ⇒ Object
Returns the value of attribute token.
10 11 12 |
# File 'lib/custom_audience.rb', line 10 def token @token end |
#users ⇒ Object
Returns the value of attribute users.
9 10 11 |
# File 'lib/custom_audience.rb', line 9 def users @users end |
Instance Method Details
#account_id ⇒ Object
44 45 46 |
# File 'lib/custom_audience.rb', line 44 def account_id 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 account_id=(account_id) attributes["account_id"] = account_id fetch_attributes! end |
#exists? ⇒ Boolean
23 24 25 |
# File 'lib/custom_audience.rb', line 23 def exists? id.present? end |
#id ⇒ Object
52 53 54 |
# File 'lib/custom_audience.rb', line 52 def id attributes["id"] end |
#name ⇒ Object
48 49 50 |
# File 'lib/custom_audience.rb', line 48 def name attributes["name"] end |
#save ⇒ Object
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 |