Class: Hisui::Management::Account
- Defined in:
- lib/hisui/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
Returns the value of attribute web_properties.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes, user, web_properties = nil) ⇒ Account
constructor
A new instance of Account.
- #path ⇒ Object
- #profiles ⇒ Object
Methods inherited from Base
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
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/hisui/management/account.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/hisui/management/account.rb', line 4 def name @name end |
#user ⇒ Object
Returns the value of attribute user.
4 5 6 |
# File 'lib/hisui/management/account.rb', line 4 def user @user end |
#web_properties ⇒ Object
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_path ⇒ Object
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.account_id } end |
Instance Method Details
#path ⇒ Object
34 35 36 |
# File 'lib/hisui/management/account.rb', line 34 def path "/accounts/#{id}" end |
#profiles ⇒ Object
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.for_account(self) end end |