2013-02-05 14:16:51 -05:00
|
|
|
# A nice object to help keep track of invited users
|
|
|
|
class InvitedList
|
|
|
|
|
|
|
|
attr_accessor :pending
|
|
|
|
attr_accessor :redeemed
|
|
|
|
attr_accessor :by_user
|
|
|
|
|
|
|
|
def initialize(user)
|
|
|
|
@pending = []
|
|
|
|
@redeemed = []
|
|
|
|
@by_user = user
|
|
|
|
|
|
|
|
invited = Invite.where(invited_by_id: @by_user.id)
|
2013-10-04 04:06:32 -04:00
|
|
|
.includes(:user => :user_stat)
|
2013-02-05 14:16:51 -05:00
|
|
|
.order(:redeemed_at)
|
|
|
|
invited.each do |i|
|
|
|
|
if i.redeemed?
|
|
|
|
@redeemed << i
|
|
|
|
else
|
|
|
|
@pending << i unless i.expired?
|
|
|
|
end
|
2013-02-07 10:45:24 -05:00
|
|
|
end
|
2013-02-05 14:16:51 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|