Class: Hisui::Management::Account

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, base_uri

Constructor Details

#initialize(attributes, user, web_properties = nil) ⇒ Account

Returns a new instance of Account.



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

def initialize(attributes, user, web_properties = nil)
  @id = attributes['id']
  @name = attributes['name']
  @user = user
  @web_properties = web_properties
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#userObject

Returns the value of attribute user.



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

def user
  @user
end

#web_propertiesObject

Returns the value of attribute web_properties.



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

def web_properties
  @web_properties
end

Class Method Details

.build_from_summary(attributes, user) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/hisui/management/account.rb', line 18

def build_from_summary(attributes, user)
  web_properties_attributes = attributes[:webProperties]

  summary_properties = web_properties_attributes.inject([]) { |props, web_property_attributes|
    web_property_attributes[:accountId] = attributes[:id]
    props << WebProperty.build_from_summary(web_property_attributes, user)
  }

  Account.new(attributes, user, summary_properties)
end

.default_pathObject



14
15
16
# File 'lib/hisui/management/account.rb', line 14

def default_path
  '/accounts'
end

.from_child(child) ⇒ Object



29
30
31
# File 'lib/hisui/management/account.rb', line 29

def from_child(child)
  all(child.user).detect { |a| a.id == child. }
end

Instance Method Details

#pathObject



34
35
36
# File 'lib/hisui/management/account.rb', line 34

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

#profilesObject



42
43
44
45
46
47
48
# File 'lib/hisui/management/account.rb', line 42

def profiles
  if web_properties
    web_properties.inject([]) { |profiles, prop| profiles.concat(prop.profiles) }
  else
    Profile.(self)
  end
end