Module: CanTango::Helpers::Debug

Included in:
Ability::Callbacks, Ability::Executor, Engine
Defined in:
lib/cantango/helpers/debug.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#debug_writerObject



36
37
38
39
# File 'lib/cantango/helpers/debug.rb', line 36

def debug_writer
  @debug_writer ||= self.class.debug_writer if self.class.respond_to? :debug_writer
  @debug_writer ||= lambda {|m| puts m }
end

#do_debug=(value) ⇒ Object (writeonly)

Sets the attribute do_debug

Parameters:

  • value

    the value to set the attribute do_debug to.



4
5
6
# File 'lib/cantango/helpers/debug.rb', line 4

def do_debug=(value)
  @do_debug = value
end

Class Method Details

.included(base) ⇒ Object



6
7
8
# File 'lib/cantango/helpers/debug.rb', line 6

def self.included base
  base.extend ClassMethods
end

Instance Method Details

#debug(msg) ⇒ Object

you can set another writer on CanTango.config.debug, fx to spec it!



23
24
25
26
27
28
29
# File 'lib/cantango/helpers/debug.rb', line 23

def debug msg
  if debug?
    return debug_writer.write msg if debug_writer.respond_to? :write
    return debug_writer.call(msg) if debug_writer.respond_to? :call
    raise "No debug_writer set!"
  end
end

#debug?Boolean

Returns:

  • (Boolean)


31
32
33
34
# File 'lib/cantango/helpers/debug.rb', line 31

def debug?
  @do_debug ||= self.class.debug? if self.class.respond_to? :debug?
  @do_debug ||= false
end