Sha256: 69580c300716618c68d1de02c54139c171e0a941ab8d690ccdb9d2b074414445
Contents?: true
Size: 1.25 KB
Versions: 3
Compression:
Stored size: 1.25 KB
Contents
module CanTango module Ability class Base include CanCan::Ability attr_reader :options, :candidate # Equivalent to a CanCan Ability#initialize call # which executes all the permission logic def initialize candidate, options = {} raise "Candidate must be something!" if !candidate @candidate, @options = candidate, options clear_rules! permit_rules execute_engines! if engines_on? end def cached? false end def rules @rules end # developer can add rules here to be included in all subclasses! def permit_rules end def clear_rules! @rules ||= default_rules end def session @session = options[:session] || {} # seperate session cache for each type of user? end def subject return candidate.active_user if masquerade_user? return candidate.active_account if masquerade_account? candidate end def config CanTango.config end Helper.modules.each do |name| include "CanTango::Ability::Helper::#{name.to_s.camelize}".constantize end protected def default_rules [] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cantango-core-0.1.2 | lib/cantango/ability/base.rb |
cantango-core-0.1.1 | lib/cantango/ability/base.rb |
cantango-core-0.1.0 | lib/cantango/ability/base.rb |