Sha256: f7e7fea123781ed279460a006ae674a2dc8c7f21c324cee32cccfcc6f41e59be

Contents?: true

Size: 633 Bytes

Versions: 5

Compression:

Stored size: 633 Bytes

Contents

class CheckoutPolicy < ApplicationPolicy
  def index?
    true
  end

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

  def create?
    user.try(:has_role?, 'Librarian')
  end

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

  def destroy?
    if record.checkin
      if user.try(:has_role?, 'Librarian')
        true
      elsif user && (user == record.user)
        true
      end
    end
  end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
enju_circulation-0.3.2 app/policies/checkout_policy.rb
enju_circulation-0.3.1 app/policies/checkout_policy.rb
enju_circulation-0.3.0 app/policies/checkout_policy.rb
enju_circulation-0.3.0.rc.1 app/policies/checkout_policy.rb
enju_circulation-0.3.0.beta.1 app/policies/checkout_policy.rb