Sha256: 8874f285ba65e2784c577d7265e85c8afd81ee13046fd5d749a66a7b8c53909d
Contents?: true
Size: 1.61 KB
Versions: 1
Compression:
Stored size: 1.61 KB
Contents
module SocialStream class Ability include CanCan::Ability def initialize(user) # Activity Objects (SocialStream.objects - [ :actor ]).map{ |obj| obj.to_s.classify.constantize }.each do |klass| can :create, klass do |k| k._activity_tie.allows?(user, 'create', 'activity') end can :read, klass do |k| k._activity_tie.allows?(user, 'read', 'activity') end can :update, klass do |k| k._activity_tie.allows?(user, 'update', 'activity') end can :destroy, klass do |k| k._activity_tie.allows?(user, 'destroy', 'activity') end end # Activities can :create, Activity do |a| a.tie.allows?(user, 'create', 'activity') end can :read, Activity do |a| a.tie.allows?(user, 'read', 'activity') end can :update, Activity do |a| a.tie.allows?(user, 'update', 'activity') end can :destroy, Activity do |a| a.tie.allows?(user, 'destroy', 'activity') end # Groups can :read, Group can :create, Group do |g| user.present? && ( g._founder == user.slug || Actor.find_by_slug!(g._founder).sent_ties.received_by(user).with_permissions('represent', nil).any? ) end can :update, Group do |g| user.present? && g.sent_ties.received_by(user).with_permissions('represent', nil).any? end can :destroy, Group do |g| user.present? && g.sent_ties.received_by(user).with_permissions('represent', nil).any? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
social_stream-0.4.3 | lib/social_stream/ability.rb |