Sha256: b49f261f31e34cb8454a602581d725da912205d91ff124254dc18912c73339aa
Contents?: true
Size: 852 Bytes
Versions: 26
Compression:
Stored size: 852 Bytes
Contents
class Dorsale::ApplicationPolicy attr_reader :user, :subject def initialize(user, subject) @user = user @subject = subject end def record subject end def policy(subject) Pundit.policy(user, subject) end def policy_scope(subject) Pundit.policy_scope(user, subject) end def self.inherited(klass) klass.define_subject_accessor! end def self.define_subject_accessor! # Dorsale::BillingMachine::InvoicePolicy -> :invoice object_type = self.to_s.demodulize.gsub("Policy", "").underscore.to_sym # Avoid user/subject conflict object_type = :other_user if object_type == :user self.send(:define_method, object_type) { subject } end private class Scope attr_reader :user, :scope def initialize(user, scope) @user = user @scope = scope end end end
Version data entries
26 entries across 26 versions & 1 rubygems