Sha256: d39ef60f55174f2330d311447e0b0a2f79ffc8df9c9a5ceffcf7826edd9edbde

Contents?: true

Size: 985 Bytes

Versions: 22

Compression:

Stored size: 985 Bytes

Contents

module UserAccountPermits
  class UserRolePermit < CanTango::RolePermit
    def initialize(ability, options = {})
      super
    end

    def static_rules
      cannot :manage, User

      can :read, Comment
      can :read, Post
      can :read, Article

      author_of(Article, :scope => :account) do |author|
        author.can :manage
      end

      author_of(Post, :scope => :account) do |author|
        author.can :manage
      end
      
      author_of(Comment, :scope => :account) do |author|
        author.can :manage
      end

     can :manage, user_account.user
   
      # # can :manage, :all    
      # scope :account do |account|
      #   account.author_of(Article) do |author|
      #     author.can :manage
      #     author.cannot :delete
      #   end          
      #     
      #   account.writer_of(Post).can :manage
      # end
      # 
      # scope :user do |user|      
      #   user.writer_of(Comment).can :manage
      # end
    end  
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
cantango-0.9.4.7 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.9.4.6 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.9.4.5 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.9.4.3 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.9.4.2 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.9.4.1 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.9.4 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.9.3.2 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.9.5 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.9.4 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.9.3 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.9.2 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.9.1 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.9 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.8.1 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.8 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.7 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.6.2 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.6.1 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb
cantango-0.8.6 spec/active_record/scenarios/user_accounts/permits/user_account_permit.rb