Improve code
This commit is contained in:
parent
5445ac9c6f
commit
700d5a1833
1 changed files with 4 additions and 16 deletions
|
@ -3,6 +3,8 @@
|
||||||
class ApplicationPolicy
|
class ApplicationPolicy
|
||||||
attr_reader :context, :record
|
attr_reader :context, :record
|
||||||
|
|
||||||
|
delegate :account, :params, to: :context, allow_nil: true
|
||||||
|
|
||||||
def initialize(context, record)
|
def initialize(context, record)
|
||||||
@context = context
|
@context = context
|
||||||
@record = record
|
@record = record
|
||||||
|
@ -46,14 +48,6 @@ class ApplicationPolicy
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def account
|
|
||||||
context&.account
|
|
||||||
end
|
|
||||||
|
|
||||||
def params
|
|
||||||
context&.params
|
|
||||||
end
|
|
||||||
|
|
||||||
def restricted?
|
def restricted?
|
||||||
Rails.application.restricted?
|
Rails.application.restricted?
|
||||||
end
|
end
|
||||||
|
@ -61,6 +55,8 @@ private
|
||||||
class Scope
|
class Scope
|
||||||
attr_reader :context, :scope
|
attr_reader :context, :scope
|
||||||
|
|
||||||
|
delegate :account, :params, to: :context, allow_nil: true
|
||||||
|
|
||||||
def initialize(context, scope)
|
def initialize(context, scope)
|
||||||
@context = context
|
@context = context
|
||||||
@scope = scope
|
@scope = scope
|
||||||
|
@ -76,14 +72,6 @@ private
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def account
|
|
||||||
context&.account
|
|
||||||
end
|
|
||||||
|
|
||||||
def params
|
|
||||||
context&.params
|
|
||||||
end
|
|
||||||
|
|
||||||
def restricted?
|
def restricted?
|
||||||
Rails.application.restricted?
|
Rails.application.restricted?
|
||||||
end
|
end
|
||||||
|
|
Reference in a new issue