Sha256: b83d873c84ccd552bae13aa6021843a3da0d484650f6f771d11a364b323a7601

Contents?: true

Size: 809 Bytes

Versions: 4

Compression:

Stored size: 809 Bytes

Contents

module CanTango
  module Ability
    module Mode
      class InvalidError < StandardError; end
      
      class Base
        include CanTango::Ability::Executor
        include CanTango::Ability::Builder

        attr_reader :ability

        delegate :session, :user, :subject, :candidate,   :to => :ability
        delegate :can, :cannot, :can?, :cannot?, :rules,  :to => :ability

        def initialize ability, options = {}
          @ability, @options = [ability, options]
        end

        def within_callbacks
          handle_callbacks :before
          raise CanTango::Ability::Mode::InvalidError, "Not  valid mode: #{self.class}" if !valid?
          yield
          handle_callbacks :after
          rules
        end

        def valid?
          true
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cantango-core-0.1.9.3 lib/cantango/ability/mode/base.rb
cantango-core-0.1.9.2 lib/cantango/ability/mode/base.rb
cantango-core-0.1.9.1 lib/cantango/ability/mode/base.rb
cantango-core-0.1.9 lib/cantango/ability/mode/base.rb