Sha256: 08c03f7de54f26eff6ab2d2058a670f432ad195a8595cd72f1054c12c7091ba0

Contents?: true

Size: 788 Bytes

Versions: 2

Compression:

Stored size: 788 Bytes

Contents

module CanTango
  module Ability
    class Base
      include CanCan::Ability
      include CanTango::Ability::Rules
      
      attr_reader :candidate, :options

      # 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
      end
      
      def execute
        clear_rules!
        calculate_rules
      end
      
      def session
        @session ||= options[:session] || {} # seperate session cache for each type of user?
      end

      # Helper.modules.each do |name|
        # include "CanTango::Ability::Helper::#{name.to_s.camelize}".constantize
      # end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cantango-core-0.1.5 lib/cantango/ability/base.rb
cantango-core-0.1.4 lib/cantango/ability/base.rb