Class: Permission

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/permission.rb

Overview

SocialStream provides a system of permissions based on the relations of the social network as roles.

Permissions and Relations

Permissions are assigned to Relations, and through relations, to 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. create activity, update tie, read post.

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 Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instances(ary) ⇒ Object

Finds or creates in the database the instances of the permissions described in ary by arrays of [ action, object ]



49
50
51
# File 'app/models/permission.rb', line 49

def instances ary
  ary.map{ |p| find_or_create_by_action_and_object *p }
end

Instance Method Details

#description(options = {}) ⇒ Object

The permission description



60
61
62
# File 'app/models/permission.rb', line 60

def description(options = {})
  i18n_description :detailed, options
end

#title(options = {}) ⇒ Object

The permission title



55
56
57
# File 'app/models/permission.rb', line 55

def title(options = {})
  i18n_description :brief, options
end