Sha256: bc2d8baf102fea0cbcc96f772b6536968789a6e69a25f697c2b2954bfb2f4661
Contents?: true
Size: 1.49 KB
Versions: 16
Compression:
Stored size: 1.49 KB
Contents
#module EnjuLibrary class Ability include CanCan::Ability def initialize(user) case user.try(:role).try(:name) when 'Administrator' can [:read, :create, :update], Bookstore can [:delete, :destroy], Bookstore do |bookstore| bookstore.items.empty? end can [:read, :create, :update], Library can [:delete, :destroy], Library do |library| library.shelves.empty? and !library.web? end can [:read, :create, :update], Shelf can [:delete, :destroy], Shelf do |shelf| shelf.items.empty? end can :manage, [ Accept, BudgetType, SearchEngine, Subscribe, Subscription ] can :update, [ LibraryGroup, RequestStatusType, RequestType ] can :read, [ LibraryGroup, RequestStatusType, RequestType ] when 'Librarian' can :manage, [ Accept, Subscribe, Subscription ] can :read, [ Bookstore, BudgetType, Library, LibraryGroup, RequestStatusType, RequestType, SearchEngine, Shelf ] when 'User' can :read, [ Library, LibraryGroup, Shelf ] else can :read, [ Library, LibraryGroup, Shelf ] end end end #end
Version data entries
16 entries across 16 versions & 1 rubygems