Class: Garb::Account
- Inherits:
-
Object
- Object
- Garb::Account
- Defined in:
- lib/garb/account.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#profiles ⇒ Object
readonly
Returns the value of attribute profiles.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(profiles) ⇒ Account
constructor
A new instance of Account.
Constructor Details
#initialize(profiles) ⇒ Account
Returns a new instance of Account.
5 6 7 8 9 |
# File 'lib/garb/account.rb', line 5 def initialize(profiles) @id = profiles.first.account_id @name = profiles.first.account_name @profiles = profiles end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/garb/account.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/garb/account.rb', line 3 def name @name end |
#profiles ⇒ Object (readonly)
Returns the value of attribute profiles.
3 4 5 |
# File 'lib/garb/account.rb', line 3 def profiles @profiles end |
Class Method Details
.all(session = Session) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/garb/account.rb', line 11 def self.all(session = Session) # Profile.all.group_to_array{|p| p.account_id}.map{|profiles| new(profiles)} profile_groups = Profile.all(session).inject({}) do |hash, profile| key = profile.account_id if hash.has_key?(key) hash[key] << profile else hash[key] = [profile] end hash end profile_groups.map {|k,v| v}.map {|profiles| new(profiles)} end |