Sha256: 07e0f66d543b2037d75c5b8641194ac65f37dc161f9c8448ce7c9ff93b65c922

Contents?: true

Size: 1.8 KB

Versions: 27

Compression:

Stored size: 1.8 KB

Contents

# {Group Groups} are the other kind of social entities supported in SocialStream::Base
#
# As with {User}, almost all the interaction with other classes in Social Stream is done
# through {Actor}. The glue between {Group} and {Actor} is in {SocialStream::Models::Subject}
#
class Group < ActiveRecord::Base
  include SocialStream::Models::Subject

  attr_accessor :_participants

  delegate :description, :description=, :to => :profile!

  after_create :create_ties

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

  private

  # Creates ties from founder to the group, based on _relation_ids,
  # and ties from the group to founder and participants.
  def create_ties
    create_ties_from_founder
    create_ties_to_participants
  end

  # Creates the ties from the founder to the group
  def create_ties_from_founder
=begin
    # FIXME: need to define a proper relation for this case. Maybe a system defined relation
    author.sent_contacts.create! :receiver_id  => actor_id,
                                 :relation_ids => _relation_ids

    if represented_author?
      user_author.sent_contacts.create! :receiver_id  => actor_id,
                                        :relation_ids => _relation_ids
    end
=end
  end
  
  # Creates the ties from the group to the participants
  def create_ties_to_participants
    participant_ids = ([ author_id, user_author_id ] | Array.wrap(@_participants)).uniq

    participant_ids.each do |a|
      c =
        sent_contacts.create! :receiver_id  => a,
                              :user_author  => user_author
      
      c.relation_ids = Array.wrap(relation_customs.sort.first.id)
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
social_stream-1.1.12 base/app/models/group.rb
social_stream-base-1.1.11 app/models/group.rb
social_stream-1.1.11 base/app/models/group.rb
social_stream-base-1.1.10 app/models/group.rb
social_stream-1.1.10 base/app/models/group.rb
social_stream-base-1.1.9 app/models/group.rb
social_stream-1.1.9 base/app/models/group.rb
social_stream-base-1.1.8 app/models/group.rb
social_stream-1.1.8 base/app/models/group.rb
social_stream-base-1.1.7 app/models/group.rb
social_stream-1.1.7 base/app/models/group.rb
social_stream-base-1.1.6 app/models/group.rb
social_stream-1.1.6 base/app/models/group.rb
social_stream-base-1.1.5 app/models/group.rb
social_stream-1.1.5 base/app/models/group.rb
social_stream-base-1.1.4 app/models/group.rb
social_stream-1.1.4 base/app/models/group.rb
social_stream-1.1.3 base/app/models/group.rb
social_stream-base-1.1.3 app/models/group.rb
social_stream-1.1.2 base/app/models/group.rb