Sha256: bcd6a4a2ebd06133be6ef18479cc666f05f4d0ef8e2a38d187babc4cbb2eb397

Contents?: true

Size: 523 Bytes

Versions: 16

Compression:

Stored size: 523 Bytes

Contents

class Ability
  include CanCan::Ability

  def initialize(user)
    case user.try(:role).try(:name)
    when 'Administrator'
      can :manage, [
        Order,
        OrderList,
        PurchaseRequest
      ]
    when 'Librarian'
      can :manage, [
        Order,
        OrderList,
        PurchaseRequest
      ]
    when 'User'
      can [:index, :create], PurchaseRequest
      can [:show, :update, :destroy], PurchaseRequest do |purchase_request|
        purchase_request.user == user
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
enju_purchase_request-0.1.0.pre5 spec/dummy/app/models/ability.rb
enju_purchase_request-0.1.0.pre4 spec/dummy/app/models/ability.rb
enju_purchase_request-0.1.0.pre3 spec/dummy/app/models/ability.rb
enju_purchase_request-0.1.0.pre2 spec/dummy/app/models/ability.rb
enju_purchase_request-0.1.0.pre spec/dummy/app/models/ability.rb
enju_purchase_request-0.0.14 spec/dummy/app/models/ability.rb
enju_purchase_request-0.0.13 spec/dummy/app/models/ability.rb
enju_purchase_request-0.0.12 spec/dummy/app/models/ability.rb
enju_purchase_request-0.0.10 spec/dummy/app/models/ability.rb
enju_purchase_request-0.0.9 spec/dummy/app/models/ability.rb
enju_purchase_request-0.0.8 spec/dummy/app/models/ability.rb
enju_purchase_request-0.0.7 spec/dummy/app/models/ability.rb
enju_purchase_request-0.0.6 spec/dummy/app/models/ability.rb
enju_purchase_request-0.0.5 spec/dummy/app/models/ability.rb
enju_purchase_request-0.0.4 spec/dummy/app/models/ability.rb
enju_purchase_request-0.0.3 spec/dummy/app/models/ability.rb