Sha256: bceab9bd87caaf0ff680bcf7c6ac39e7f0479b55d3388046dd087a4c98d17ba1

Contents?: true

Size: 615 Bytes

Versions: 2

Compression:

Stored size: 615 Bytes

Contents

class ApplicationPolicy
  attr_reader :user, :record

  def initialize(user, record)
    @user = user
    @record = record
  end

  def index?
    false
  end

  def show?
    scope.where(:id => record.id).exists?
  end

  def create?
    false
  end

  def new?
    create?
  end

  def update?
    false
  end

  def edit?
    update?
  end

  def destroy?
    false
  end

  def scope
    Regulator.policy_scope!(user, record.class)
  end

  class Scope
    attr_reader :user, :scope

    def initialize(user, scope)
      @user = user
      @scope = scope
    end

    def resolve
      scope
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
regulator-0.1.3 lib/generators/regulator/install/templates/application_policy.rb
regulator-0.1.2 lib/generators/regulator/install/templates/application_policy.rb