Module: Calib::Pundit::Nestable

Extended by:
ActiveSupport::Concern
Defined in:
lib/calib/pundit/nestable.rb

Overview

Instance Method Summary collapse

Instance Method Details

#authorize(record, query = nil) ⇒ Object



18
19
20
21
# File 'lib/calib/pundit/nestable.rb', line 18

def authorize(record, query = nil)
  super self.class.namespace + [record], query
  record
end

#policy(record) ⇒ Object



23
24
25
26
# File 'lib/calib/pundit/nestable.rb', line 23

def policy(record)
  # if record is Array, as already namespace array
  super record.is_a?(Array) ? record : self.class.namespace + [record]
end

#policy_scope(scope) ⇒ Object



14
15
16
# File 'lib/calib/pundit/nestable.rb', line 14

def policy_scope(scope)
  super self.class.namespace + [scope]
end