Sha256: ae25de99dcf97d6d45067ccf36a17cf8e6eeebd02a84c7093bd261baba018625

Contents?: true

Size: 721 Bytes

Versions: 1

Compression:

Stored size: 721 Bytes

Contents

class AccountPolicy < AbstractResourcePolicy

  class Scope < Scope
    def resolve
      return Account.where(1==2) if current_user.nil?
      if current_user.admin?
        scope.all
      else
        scope.where(id: current_user.account.id)
      end
    end
  end



  def new?
    current_user.admin?
  end

  def index?
    @current_user.admin? || @current_user.account_admin?
  end

  def create?
    @current_user.admin?
  end

  def show?
    @current_user.admin? or @current_user.account==@model
  end

  def edit?
    @current_user.admin? or @current_user.account==@model
  end

  def update?
    @current_user.admin? or @current_user.account==@model
  end

  def destroy?
    @current_user.admin?
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oxen_account-0.1.1 app/policies/account_policy.rb