Class: CanTango::Ability::Mode::Base

Inherits:
Object
  • Object
show all
Includes:
Builder, Executor
Defined in:
lib/cantango/ability/mode/base.rb

Direct Known Subclasses

NoCache

Instance Attribute Summary collapse

Attributes included from Helpers::Debug

#debug_writer, #do_debug

Instance Method Summary collapse

Methods included from Builder

included

Methods included from Executor

#execute, included

Methods included from Callbacks

#handle_callbacks, included

Methods included from Helpers::Debug

#debug, #debug?, included

Methods included from Rules

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

Constructor Details

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

Returns a new instance of Base.



15
16
17
# File 'lib/cantango/ability/mode/base.rb', line 15

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

Instance Attribute Details

#abilityObject (readonly)

Returns the value of attribute ability.



10
11
12
# File 'lib/cantango/ability/mode/base.rb', line 10

def ability
  @ability
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/cantango/ability/mode/base.rb', line 27

def valid?
  true
end

#within_callbacksObject



19
20
21
22
23
24
25
# File 'lib/cantango/ability/mode/base.rb', line 19

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