Module: Kantox::Strategies::PolicyFactory
- Defined in:
- lib/kantox/roles/strategies/pundit.rb
Overview
Policy factory for pundit.
Class Method Summary collapse
Class Method Details
.lookup(name) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/kantox/roles/strategies/pundit.rb', line 22 def lookup name klazz = "#{name}Policy" if Kantox::Policies.const_defined? klazz Kantox::Policies.const_get klazz else c = Kantox::Policies.const_set(klazz, Class.new(ApplicationPolicy) { def method_missing m, *args, &cb if m.to_s[-1] == '?' Kantox::Helpers.error "Missing policy for «#{self.class.name}##{m}». You should define it explicitly." nil else super end end }) c.const_set('Scope', Class.new(ApplicationPolicy::Scope) { def resolve scope end }) c end end |