1
0
Fork 0
This repository has been archived on 2023-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/app/policies/application_policy.rb

73 lines
874 B
Ruby
Raw Normal View History

2018-11-30 00:02:04 +00:00
# frozen_string_literal: true
class ApplicationPolicy
2018-12-02 11:04:30 +00:00
attr_reader :context, :record
2018-11-30 00:02:04 +00:00
2018-12-02 11:04:30 +00:00
def initialize(context, record)
@context = context
2018-11-30 00:02:04 +00:00
@record = record
end
2018-12-01 11:17:55 +00:00
# :nocov:
2018-11-30 00:02:04 +00:00
def index?
false
end
def show?
false
end
def create?
false
end
def new?
create?
end
def update?
false
end
def edit?
update?
end
def destroy?
false
end
2018-12-01 11:17:55 +00:00
# :nocov:
def policy(record)
2018-12-02 11:04:30 +00:00
Pundit.policy context, record
end
2018-11-30 00:02:04 +00:00
class Scope
2018-12-02 11:04:30 +00:00
attr_reader :context, :scope
2018-11-30 00:02:04 +00:00
2018-12-02 11:04:30 +00:00
def initialize(context, scope)
@context = context
2018-11-30 00:02:04 +00:00
@scope = scope
end
2018-12-01 11:17:55 +00:00
# :nocov:
2018-11-30 00:02:04 +00:00
def resolve
2018-11-30 00:17:26 +00:00
scope.none
2018-11-30 00:02:04 +00:00
end
2018-12-01 11:17:55 +00:00
# :nocov:
2018-11-30 00:02:04 +00:00
end
2018-12-02 11:04:30 +00:00
class Context
2018-12-05 23:20:50 +00:00
attr_reader :account, :guest_account
2018-12-02 11:04:30 +00:00
2018-12-05 23:20:50 +00:00
def initialize(account:, guest_account:)
2018-12-02 11:04:30 +00:00
@account = account
2018-12-05 23:20:50 +00:00
@guest_account = guest_account
2018-12-02 11:04:30 +00:00
end
end
2018-11-30 00:02:04 +00:00
end