Sha256: 9317cad2dd6123d0fd908067e6e3c3eec4b017076e5dde0ff2355dc778b23af8

Contents?: true

Size: 816 Bytes

Versions: 5

Compression:

Stored size: 816 Bytes

Contents

class Relation::Public < Relation
  attr_accessor :actor

  after_create :initialize_tie

  scope :actor, lambda { |a|
    joins(:ties).merge(Tie.sent_by(a))
  }

  class << self
    def default_for(actor)
      create! :actor => actor
    end

    # The {Relation::Public} belonging to actor
    def of(actor)
      actor(actor).first
    end
  end

  # A {Relation::Public public relation} is always the weakest
  def <=>(relation)
    1
  end

  # The name of public relation
  def name
    I18n.t('relation_public.name')
  end

  # Are we supporting custom permissions for {Relation::Public}? Not by the moment.
  def allow?(user, action, object)
    action == 'read' && object == 'activity'
  end

  private

  def initialize_tie
    ties.create! :sender => actor,
                 :receiver => actor
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
social_stream-base-0.5.2 app/models/relation/public.rb
social_stream-base-0.5.1 app/models/relation/public.rb
social_stream-base-0.5.0 app/models/relation/public.rb
social_stream-0.4.6 app/models/relation/public.rb
social_stream-0.4.5 app/models/relation/public.rb