Sha256: f197daf4f9791dead602dfd3716fd75024c4b4618e3c86a204bcacca8b4196ce

Contents?: true

Size: 1.91 KB

Versions: 126

Compression:

Stored size: 1.91 KB

Contents

# SocialStream provides a system of permissions based on the {Relation relations}
# of the social network as roles.
#
# = Permissions and Relations
#
# Permissions are assigned to {Relation Relations}, and through relations, to {Tie Ties}. 
# When a sender establishes a {Tie} with a receiver, she is granting to the receiver
# the permissions assigned to {Relation} of the {Tie} she has just established.
#
# For example, when _Alice_ establishes a _friend_ tie to _Bob_, she is granting
# him the permissions associated with her _friend_ relation. Alice's _friend_ relation may
# have different permissions from Bob's _friend_ relation.
#
# = Permissions description
#
# Permissions are composed by *action* and *object*. Action and object
# are typical in content management systems, e.g. <tt>create activity</tt>,
# <tt>update tie</tt>, <tt>read post</tt>.
#
# == Actions
#
# Current available actions are:
#
# +create+:: add a new instance of something (activity, tie, post, etc)
# +read+::   view something
# +update+::  modify something
# +destroy+:: delete something
# +follow+::  subscribe to activity updates from the receiver of the tie
# +represent+:: give the receiver rights to act as if he were me.
#
# == Objectives
#
# +activity+:: all the objects in a wall: posts, comments
#
# Other objects currently not implemented could be +tie+, +post+, +comment+ or +message+
#
#
class Permission < ActiveRecord::Base
  has_many :relation_permissions, :dependent => :destroy
  has_many :relations, :through => :relation_permissions

  %w(represent follow).each do |p|
    scope p, where(:action => p) # scope :represent, where(:action => 'represent')
  end

  # An explanation of the permissions. Type can be brief or detailed.
  # If detailed, description includes more information about the relation
  def description(type, options = {})
    I18n.t "permission.description.#{ type }.#{ action }.#{ object || "nil" }",
           options
  end
end

Version data entries

126 entries across 126 versions & 4 rubygems

Version Path
social_stream-0.20.2 base/app/models/permission.rb
social_stream-base-0.15.2 app/models/permission.rb
social_stream-0.20.1 base/app/models/permission.rb
social_stream-base-0.15.1 app/models/permission.rb
social_stream-0.20.0 base/app/models/permission.rb
social_stream-base-0.15.0 app/models/permission.rb
social_stream-0.19.3 base/app/models/permission.rb
social_stream-base-0.14.3 app/models/permission.rb
social_stream-0.19.2 base/app/models/permission.rb
social_stream-base-0.14.2 app/models/permission.rb
social_stream-0.19.1 base/app/models/permission.rb
social_stream-base-0.14.1 app/models/permission.rb
vkhater-social_stream-0.16.3.3 base/app/models/permission.rb
vkhater-social_stream-base-0.11.2 app/models/permission.rb
social_stream-0.19.0 base/app/models/permission.rb
social_stream-base-0.14.0 app/models/permission.rb
social_stream-0.18.2 base/app/models/permission.rb
social_stream-base-0.13.2 app/models/permission.rb
social_stream-0.18.1 base/app/models/permission.rb
social_stream-base-0.13.1 app/models/permission.rb