Sha256: 78c6144db65407ae128bd15982573270c3049211ec0dd8d4d79a5a6ff36ff668

Contents?: true

Size: 1009 Bytes

Versions: 22

Compression:

Stored size: 1009 Bytes

Contents

class UserRolePermit < CanTango::RolePermit
  def initialize ability
    super
  end

  protected

  def static_rules
    
    cannot :manage, User

    can :read, Comment
    can :read, any(/Post/)
    can :read, Article do |article|
    end

    can :write, any(/Article/)

    # Following will just return empty array of targets:
    # can :write, []
    can :write, any(/Unable to constantize/)

    # Todo.new.author - is attribute
    author_of(Article, Post, Comment) do |author|
      author.can :manage
    end

    # Todo.new.authors is Array
    author_of(Todo) do |author|
      author.can :write
    end

    # # 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

    licenses :musicians
  end  
end

Version data entries

22 entries across 22 versions & 1 rubygems

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