Class: Legato::Management::WebProperty

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

Constant Summary collapse

GA_ATTRIBUTES =
{
  :id => 'id',
  :name => 'name',
  :account_id => 'accountId',
  :website_url => 'websiteUrl'
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Finder

all, base_uri, get

Constructor Details

#initialize(attributes, user) ⇒ WebProperty

Returns a new instance of WebProperty.



25
26
27
28
29
30
31
32
33
# File 'lib/legato/management/web_property.rb', line 25

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



43
44
45
# File 'lib/legato/management/web_property.rb', line 43

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

#attributesObject

Returns the value of attribute attributes.



22
23
24
# File 'lib/legato/management/web_property.rb', line 22

def attributes
  @attributes
end

#profilesObject



39
40
41
# File 'lib/legato/management/web_property.rb', line 39

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

#userObject

Returns the value of attribute user.



22
23
24
# File 'lib/legato/management/web_property.rb', line 22

def user
  @user
end

Class Method Details

.build_from_summary(attributes, user, account) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/legato/management/web_property.rb', line 53

def self.build_from_summary(attributes, user, )
  profiles = attributes.delete('profiles') || attributes.delete(:profiles)

  WebProperty.new(attributes, user).tap { |web_property|
    web_property. = 
    web_property.profiles = profiles.map { |profile|
      profile['accountId'] = .id
      profile['webPropertyId'] = web_property.id
      Profile.build_from_summary(profile, user, , web_property)
    }
  }
end

.default_pathObject



6
7
8
# File 'lib/legato/management/web_property.rb', line 6

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

.for_account(account) ⇒ Object



35
36
37
# File 'lib/legato/management/web_property.rb', line 35

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

.from_child(child) ⇒ Object



47
48
49
50
51
# File 'lib/legato/management/web_property.rb', line 47

def self.from_child(child)
  path = new({:id => child.web_property_id, :account_id => child.}, nil).path

  get(child.user, path)
end

Instance Method Details

#pathObject



10
11
12
# File 'lib/legato/management/web_property.rb', line 10

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