Class: Legato::Management::WebProperty
- Inherits:
-
Object
- Object
- Legato::Management::WebProperty
- 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
- #account ⇒ Object
-
#attributes ⇒ Object
Returns the value of attribute attributes.
- #profiles ⇒ Object
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
- .build_from_summary(attributes, user, account) ⇒ Object
- .default_path ⇒ Object
- .for_account(account) ⇒ Object
- .from_child(child) ⇒ Object
Instance Method Summary collapse
-
#initialize(attributes, user) ⇒ WebProperty
constructor
A new instance of WebProperty.
- #path ⇒ Object
Methods included from Finder
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
#account ⇒ Object
43 44 45 |
# File 'lib/legato/management/web_property.rb', line 43 def account @account ||= Account.from_child(self) end |
#attributes ⇒ Object
Returns the value of attribute attributes.
22 23 24 |
# File 'lib/legato/management/web_property.rb', line 22 def attributes @attributes end |
#profiles ⇒ Object
39 40 41 |
# File 'lib/legato/management/web_property.rb', line 39 def profiles @profiles ||= Profile.for_web_property(self) end |
#user ⇒ Object
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, account) profiles = attributes.delete('profiles') || attributes.delete(:profiles) WebProperty.new(attributes, user).tap { |web_property| web_property.account = account web_property.profiles = profiles.map { |profile| profile['accountId'] = account.id profile['webPropertyId'] = web_property.id Profile.build_from_summary(profile, user, account, web_property) } } end |
.default_path ⇒ Object
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.for_account(account) all(account.user, account.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.account_id}, nil).path get(child.user, path) end |
Instance Method Details
#path ⇒ Object
10 11 12 |
# File 'lib/legato/management/web_property.rb', line 10 def path "/accounts/#{account_id}/webproperties/#{id}" end |