2018-11-30 00:02:04 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ApplicationPolicy
|
2019-09-15 13:26:15 +00:00
|
|
|
attr_reader :account, :record
|
2018-11-30 00:02:04 +00:00
|
|
|
|
2019-09-15 13:26:15 +00:00
|
|
|
def initialize(account, record)
|
|
|
|
@account = account
|
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:
|
|
|
|
|
2018-11-30 08:47:54 +00:00
|
|
|
def policy(record)
|
2018-12-13 03:09:49 +00:00
|
|
|
Pundit.policy account, record
|
2018-11-30 08:47:54 +00:00
|
|
|
end
|
|
|
|
|
2019-09-11 22:25:58 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def restricted?
|
|
|
|
Rails.application.restricted?
|
|
|
|
end
|
|
|
|
|
2018-11-30 00:02:04 +00:00
|
|
|
class Scope
|
2019-09-15 13:26:15 +00:00
|
|
|
attr_reader :account, :scope
|
2019-09-11 23:02:10 +00:00
|
|
|
|
2019-09-15 13:26:15 +00:00
|
|
|
def initialize(account, scope)
|
|
|
|
@account = account
|
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
|
|
|
|
2019-09-09 22:22:17 +00:00
|
|
|
# :nocov:
|
2019-09-09 22:02:46 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def restricted?
|
|
|
|
Rails.application.restricted?
|
|
|
|
end
|
|
|
|
end
|
2018-11-30 00:02:04 +00:00
|
|
|
end
|