Class: CanTango::Ability::Executor::Base

Inherits:
Base
  • Object
show all
Includes:
Builder, Callbacks, CanTango::Ability::Executor
Defined in:
lib/cantango/ability/executor/base.rb

Direct Known Subclasses

Modal

Instance Attribute Summary collapse

Attributes included from Helpers::Debug

#debug_writer, #do_debug

Attributes inherited from Base

#candidate

Instance Method Summary collapse

Methods included from Builder

included

Methods included from Callbacks

#handle_callbacks, included, #within_callbacks

Methods included from Helpers::Debug

#debug, #debug?, included

Methods included from CanTango::Ability::Executor

#execute, included

Methods included from Rules

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

Methods inherited from Base

#execute, #session

Constructor Details

#initialize(ability, options = {}) ⇒ Base

Returns a new instance of Base.

Raises:

  • (ArgumentError)


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

def initialize ability, options = {}
  raise ArgumentError, "Ability must be something!" if !ability
  raise ArgumentError, "Ability must be a kind of CanTango::Ability::Base" if !ability.kind_of?(CanTango::Ability::Base)
  raise ArgumentError, "Options must be a hash" if !options.kind_of?(Hash)
  @ability = ability
  @options ||= options
end

Instance Attribute Details

#abilityObject (readonly)

Returns the value of attribute ability.



7
8
9
# File 'lib/cantango/ability/executor/base.rb', line 7

def ability
  @ability
end

#executedObject (readonly)

Returns the value of attribute executed.



7
8
9
# File 'lib/cantango/ability/executor/base.rb', line 7

def executed
  @executed
end

#modesObject (readonly)

Returns the value of attribute modes.



7
8
9
# File 'lib/cantango/ability/executor/base.rb', line 7

def modes
  @modes
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/cantango/ability/executor/base.rb', line 7

def options
  @options
end

Instance Method Details

#calculate_rulesObject



30
31
32
# File 'lib/cantango/ability/executor/base.rb', line 30

def calculate_rules
  super
end

#executed?Boolean

def self.inherited(base)

base.send :include, CanTango::Helpers::Debug
base.send :include, CanTango::Ability::Executor
base.send :include, CanTango::Ability::Rules
base.send :include, CanTango::Ability::Callbacks

end

Returns:

  • (Boolean)


26
27
28
# File 'lib/cantango/ability/executor/base.rb', line 26

def executed?
  @executed
end