Module: CanTango::Ability::Executor

Includes:
Callbacks, Rules, Helpers::Debug
Included in:
Base, Mode::Base
Defined in:
lib/cantango/ability/executor.rb,
lib/cantango/ability/executor/base.rb,
lib/cantango/ability/executor/modal.rb

Defined Under Namespace

Classes: Base, Modal

Instance Attribute Summary

Attributes included from Helpers::Debug

#debug_writer, #do_debug

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Callbacks

#handle_callbacks, #within_callbacks

Methods included from Helpers::Debug

#debug, #debug?

Methods included from Rules

#calculate_rules, #clear_rules!, #default_rules, #normalize_rules!, #rules

Class Method Details

.included(base) ⇒ Object



11
12
13
14
15
# File 'lib/cantango/ability/executor.rb', line 11

def self.included(base)
  base.send :include, CanTango::Helpers::Debug
  base.send :include, CanTango::Ability::Rules
  base.send :include, CanTango::Ability::Callbacks
end

Instance Method Details

#executeObject

the way to abort execution is to raise an exception!



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/cantango/ability/executor.rb', line 18

def execute
  within_callbacks do
    clear_rules!
    calculate_rules
  end
rescue Exception => e
  debug e.message
ensure
  @executed = true
  rules
end