Class: Garb::Management::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/garb/management/account.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/garb/management/account.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/garb/management/account.rb', line 5

def name
  @name
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/garb/management/account.rb', line 4

def path
  @path
end

#sessionObject

Returns the value of attribute session.



4
5
6
# File 'lib/garb/management/account.rb', line 4

def session
  @session
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'lib/garb/management/account.rb', line 5

def title
  @title
end

Class Method Details

.all(session = Session) ⇒ Object



7
8
9
10
11
# File 'lib/garb/management/account.rb', line 7

def self.all(session = Session)
  feed = Feed.new(session, '/accounts') # builds request and parses response

  feed.entries.map {|entry| new_from_entry(entry, session)}
end

.new_from_entry(entry, session) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/garb/management/account.rb', line 13

def self.new_from_entry(entry, session)
   = new
  .session = session
  .path = Garb.parse_link(entry, "self").gsub(Feed::BASE_URL, '')
  .title = entry['title'].gsub('Google Analytics Account ', '')
  .properties = Garb.parse_properties(entry)
  
end

Instance Method Details

#profilesObject



31
32
33
# File 'lib/garb/management/account.rb', line 31

def profiles
  @profiles ||= Profile.(self)
end

#properties=(properties) ⇒ Object



22
23
24
25
# File 'lib/garb/management/account.rb', line 22

def properties=(properties)
  self.id = properties["account_id"]
  self.name = properties["account_name"]
end

#web_propertiesObject



27
28
29
# File 'lib/garb/management/account.rb', line 27

def web_properties
  @web_properties ||= WebProperty.(self) # will call path
end