Class: Legato::Management::Profile

Inherits:
Object
  • Object
show all
Extended by:
Finder
Includes:
ProfileMethods
Defined in:
lib/legato/management/profile.rb

Constant Summary collapse

GA_ATTRIBUTES =
{
  :id => 'id',
  :name => 'name',
  :account_id => 'accountId',
  :web_property_id => 'webPropertyId'
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Finder

all, base_uri, get

Methods included from ProfileMethods

add_profile_method, method_name_from_klass

Constructor Details

#initialize(attributes, user) ⇒ Profile

Returns a new instance of Profile.



27
28
29
30
31
32
33
34
35
# File 'lib/legato/management/profile.rb', line 27

def initialize(attributes, user)
  self.user = user

  GA_ATTRIBUTES.each do |key,string_key|
    self.send("#{key}=", attributes.delete(string_key) || attributes.delete(key))
  end

  self.attributes = attributes
end

Instance Attribute Details

#accountObject



45
46
47
# File 'lib/legato/management/profile.rb', line 45

def 
  @account ||= Account.from_child(self)
end

#attributesObject

Returns the value of attribute attributes.



24
25
26
# File 'lib/legato/management/profile.rb', line 24

def attributes
  @attributes
end

#userObject

Returns the value of attribute user.



24
25
26
# File 'lib/legato/management/profile.rb', line 24

def user
  @user
end

#web_propertyObject



49
50
51
# File 'lib/legato/management/profile.rb', line 49

def web_property
  @web_property ||= WebProperty.from_child(self)
end

Class Method Details

.build_from_summary(attributes, user, account, web_property) ⇒ Object



57
58
59
60
61
62
# File 'lib/legato/management/profile.rb', line 57

def self.build_from_summary(attributes, user, , web_property)
  Profile.new(attributes, user).tap { |profile|
    profile. = 
    profile.web_property = web_property
  }
end

.default_pathObject



8
9
10
# File 'lib/legato/management/profile.rb', line 8

def self.default_path
  "/accounts/~all/webproperties/~all/profiles"
end

.for_account(account) ⇒ Object



37
38
39
# File 'lib/legato/management/profile.rb', line 37

def self.()
  all(.user, .path+'/webproperties/~all/profiles')
end

.for_web_property(web_property) ⇒ Object



41
42
43
# File 'lib/legato/management/profile.rb', line 41

def self.for_web_property(web_property)
  all(web_property.user, web_property.path+'/profiles')
end

Instance Method Details

#goalsObject



53
54
55
# File 'lib/legato/management/profile.rb', line 53

def goals
  Goal.for_profile(self)
end

#pathObject



12
13
14
# File 'lib/legato/management/profile.rb', line 12

def path
  "/accounts/#{}/webproperties/#{web_property_id}/profiles/#{id}"
end