Module: CanTango::Ability::Callbacks

Includes:
Helpers::Debug
Included in:
Executor, Executor::Base
Defined in:
lib/cantango/ability/callbacks.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary

Attributes included from Helpers::Debug

#debug_writer, #do_debug

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Debug

#debug, #debug?

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/cantango/ability/callbacks.rb', line 5

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#handle_callbacks(type) ⇒ Object

should execute :after_execute callbacks

Raises:

  • (ArgumentError)


24
25
26
27
28
# File 'lib/cantango/ability/callbacks.rb', line 24

def handle_callbacks type
  callbacks_method = "#{type}_execute_callbacks"
  raise ArgumentError, "Not a valid callback type: #{type}" if !self.class.respond_to? callbacks_method
  self.class.send(callbacks_method).each {|callback| send(callback) }
end

#within_callbacks(&block) ⇒ Object



30
31
32
33
34
# File 'lib/cantango/ability/callbacks.rb', line 30

def within_callbacks &block
  handle_callbacks :before
  yield
  handle_callbacks :after
end