Class: Group

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
SocialStream::Models::Subject
Defined in:
app/models/group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_founderObject

Returns the value of attribute _founder.



4
5
6
# File 'app/models/group.rb', line 4

def _founder
  @_founder
end

#_participantsObject

Returns the value of attribute _participants.



5
6
7
# File 'app/models/group.rb', line 5

def _participants
  @_participants
end

Instance Method Details

#create_founderObject

Creates the ties between the group and the founder



28
29
30
31
32
33
34
# File 'app/models/group.rb', line 28

def create_founder
  founder =
    Actor.find_by_slug(_founder) || raise("Cannot create group without founder")

  sent_contacts.create! :receiver => founder,
                        :relation_ids => Array(relation_customs.sort.first.id)
end

#create_participantsObject

Creates the ties between the group and the participants



37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/group.rb', line 37

def create_participants
   return if @_participants.blank?
  
   @_participants.each do |participant|
    
     participant_actor = Actor.find(participant)

     sent_contacts.create! :receiver => participant_actor,
                           :relation_ids => Array(relation_customs.sort.first.id)
   end
end

#followersObject



16
17
18
# File 'app/models/group.rb', line 16

def followers
  contact_subjects(:subject_type => :user, :direction => :received)
end

#profile!Object



12
13
14
# File 'app/models/group.rb', line 12

def profile!
  actor!.profile || actor!.build_profile
end

#recent_groupsObject



20
21
22
23
24
25
# File 'app/models/group.rb', line 20

def recent_groups
  contact_subjects(:type => :group, :direction => :sent) do |q|
    q.select("contacts.created_at").
      merge(Contact.recent)
  end
end