Sha256: 6586b4cfa378ea7dcea294547c2b048dd974f6d1f1ee7eba288e71c474e779c8
Contents?: true
Size: 930 Bytes
Versions: 1
Compression:
Stored size: 930 Bytes
Contents
# Main class for all the **Faalis** Policy classes. # It's totally a minimume Policy. class Faalis::ApplicationPolicy attr_reader :user, :record def initialize(user, record) @user = user @record = record end def authorize?(action) return false if @user.nil? return true if @user.admin? # Check for ownership of the reocrd record_class = @record.class unless [Class, String, Symbol].include?(record_class) return false if !@user.owned? @record @record = @record.class end user.can? action, @record.to_s end def method_missing(m, *args, &block_given) return authorize? m.to_s[0..-2] if m.to_s =~ /.*\?$/ super end def scope Pundit.policy_scope!(@user, record.class) end class Scope attr_reader :user, :scope def initialize(user, scope) @@user = @user @scope = scope end def resolve scope end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
faalis-2.0.0.rc4 | app/policies/faalis/application_policy.rb |