Sha256: 5fad2efd69d7b85cbe3973231f4d4eb20b1c480e4cdad7a8f60b5051c8231d67
Contents?: true
Size: 679 Bytes
Versions: 10
Compression:
Stored size: 679 Bytes
Contents
module Garb class Account attr_reader :id, :name, :profiles def initialize(profiles) @id = profiles.first.account_id @name = profiles.first.account_name @profiles = profiles end 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 end end
Version data entries
10 entries across 10 versions & 4 rubygems