Sha256: a626647c450a49a51eefca9d532d84494ebfbfdc92ed619d0be3b6a934cee945

Contents?: true

Size: 389 Bytes

Versions: 6

Compression:

Stored size: 389 Bytes

Contents

class PurchaseRequestPolicy < ApplicationPolicy
  def index?
    true if user.try(:has_role?, 'User')
  end

  def show?
    if user.try(:has_role?, 'Librarian')
      true
    elsif user.try(:has_role?, 'User')
      true if record.user == user
    end
  end

  def create?
    true if user.try(:has_role?, 'User')
  end

  def update?
    show?
  end

  def destroy?
    show?
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
enju_purchase_request-0.3.2 app/policies/purchase_request_policy.rb
enju_purchase_request-0.3.1 app/policies/purchase_request_policy.rb
enju_purchase_request-0.3.0.beta.1 app/policies/purchase_request_policy.rb
enju_purchase_request-0.2.1 app/policies/purchase_request_policy.rb
enju_purchase_request-0.2.0 app/policies/purchase_request_policy.rb
enju_purchase_request-0.2.0.beta.2 app/policies/purchase_request_policy.rb