Sha256: 543399c34a277ba33cfe5dade8a4207bdae5d28ea206692f84c7fb8fdc24a79d

Contents?: true

Size: 557 Bytes

Versions: 3

Compression:

Stored size: 557 Bytes

Contents

module NippoCore
  class ReportPolicy < ApplicationPolicy
    attr_reader :user, :group, :report

    def initialize(user, report)
      @user = user
      @report = report
      @group = @report.group
    end

    # TODO: remove
    def index?
      @group.member?(user)
    end

    def show?
      @group.member?(user)
    end

    def new?
      @group.member?(user)
    end

    def create?
      @group.member?(user)
    end

    def edit?
      @report.user_id == @user.id
    end

    def update?
      @report.user_id == @user.id
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nippo_core-1.0.2 app/policies/nippo_core/report_policy.rb
nippo_core-1.0.1 app/policies/nippo_core/report_policy.rb
nippo_core-1.0.0 app/policies/nippo_core/report_policy.rb