Class: Legato::Management::Account
- Inherits:
-
Object
- Object
- Legato::Management::Account
- Extended by:
- Finder
- Defined in:
- lib/legato/management/account.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#user ⇒ Object
Returns the value of attribute user.
- #web_properties ⇒ Object
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes, user) ⇒ Account
constructor
A new instance of Account.
- #path ⇒ Object
- #profiles ⇒ Object
Methods included from Finder
Constructor Details
#initialize(attributes, user) ⇒ Account
Returns a new instance of Account.
17 18 19 20 21 22 |
# File 'lib/legato/management/account.rb', line 17 def initialize(attributes, user) self.user = user self.id = attributes['id'] || attributes[:id] self.name = attributes['name'] || attributes[:name] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
14 15 16 |
# File 'lib/legato/management/account.rb', line 14 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/legato/management/account.rb', line 14 def name @name end |
#user ⇒ Object
Returns the value of attribute user.
14 15 16 |
# File 'lib/legato/management/account.rb', line 14 def user @user end |
#web_properties ⇒ Object
24 25 26 |
# File 'lib/legato/management/account.rb', line 24 def web_properties @web_properties ||= WebProperty.for_account(self) end |
Class Method Details
.build_from_summary(attributes, user) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/legato/management/account.rb', line 38 def self.build_from_summary(attributes, user) properties = attributes['webProperties'] || attributes[:webProperties] Account.new(attributes, user).tap { |account| account.web_properties = properties.map { |property| property['accountId'] = account.id WebProperty.build_from_summary(property, user, account) } } end |
.default_path ⇒ Object
6 7 8 |
# File 'lib/legato/management/account.rb', line 6 def self.default_path "/accounts" end |
.from_child(child) ⇒ Object
34 35 36 |
# File 'lib/legato/management/account.rb', line 34 def self.from_child(child) all(child.user).detect {|a| a.id == child.account_id} end |
Instance Method Details
#path ⇒ Object
10 11 12 |
# File 'lib/legato/management/account.rb', line 10 def path "/accounts/#{id}" end |
#profiles ⇒ Object
28 29 30 31 32 |
# File 'lib/legato/management/account.rb', line 28 def profiles @web_properties ? @web_properties.map { |property| property.profiles }.flatten : Profile.for_account(self) end |