Class: Group
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Group
- Includes:
- SocialStream::Models::Subject
- Defined in:
- app/models/group.rb
Instance Attribute Summary collapse
-
#_founder ⇒ Object
Returns the value of attribute _founder.
-
#_participants ⇒ Object
Returns the value of attribute _participants.
Instance Method Summary collapse
-
#create_founder ⇒ Object
Creates the ties between the group and the founder.
-
#create_participants ⇒ Object
Creates the ties between the group and the participants.
- #followers ⇒ Object
- #profile! ⇒ Object
- #recent_groups ⇒ Object
Instance Attribute Details
#_founder ⇒ Object
Returns the value of attribute _founder.
4 5 6 |
# File 'app/models/group.rb', line 4 def _founder @_founder end |
#_participants ⇒ Object
Returns the value of attribute _participants.
5 6 7 |
# File 'app/models/group.rb', line 5 def _participants @_participants end |
Instance Method Details
#create_founder ⇒ Object
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_participants ⇒ Object
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 |
#followers ⇒ Object
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_groups ⇒ Object
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 |