Sha256: ebe9c13f9155dae116f577a4213bc62b3f8f893d4d6202bdbb4f5b4513ddc26e

Contents?: true

Size: 803 Bytes

Versions: 35

Compression:

Stored size: 803 Bytes

Contents

class Ability
  include CanCan::Ability

  def initialize(user)
    case user.try(:role).try(:name)
    when 'Administrator'
      can :manage, Message
      can [:read, :update, :destroy], MessageRequest
      can [:read, :update], MessageTemplate
    when 'Librarian'
      can [:index, :create], Message
      can [:update], Message do |message|
        message.sender == user
      end
      can [:show, :destroy], Message do |message|
        message.receiver == user
      end
      can [:read, :update, :destroy], MessageRequest
      can :read, MessageTemplate
    when 'User'
      can [:read, :destroy], Message do |message|
        message.receiver == user
      end
      can :index, Message
      can :show, Message do |message|
        message.receiver == user
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
enju_trunk_message-0.1.14.pre3 spec/dummy/app/models/ability.rb
enju_message-0.1.14.pre3 spec/dummy/app/models/ability.rb
enju_message-0.1.14.pre2 spec/dummy/app/models/ability.rb
enju_message-0.1.14.pre spec/dummy/app/models/ability.rb
enju_message-0.1.13 spec/dummy/app/models/ability.rb
enju_message-0.1.12 spec/dummy/app/models/ability.rb
enju_message-0.1.11 spec/dummy/app/models/ability.rb
enju_message-0.0.25 spec/dummy/app/models/ability.rb
enju_message-0.1.9 spec/dummy/app/models/ability.rb
enju_message-0.0.24 spec/dummy/app/models/ability.rb
enju_message-0.1.8 spec/dummy/app/models/ability.rb
enju_message-0.0.23 spec/dummy/app/models/ability.rb
enju_message-0.1.7 spec/dummy/app/models/ability.rb
enju_message-0.0.22 spec/dummy/app/models/ability.rb
enju_message-0.1.6 spec/dummy/app/models/ability.rb
enju_message-0.0.21 spec/dummy/app/models/ability.rb
enju_message-0.1.5 spec/dummy/app/models/ability.rb
enju_message-0.0.20 spec/dummy/app/models/ability.rb
enju_message-0.1.4 spec/dummy/app/models/ability.rb
enju_message-0.1.3 spec/dummy/app/models/ability.rb