Class: CanTango::Config::Debug

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/cantango/config/debug.rb

Overview

Note: This config feature is currently not used, but could potentially be of use in the future

Instance Method Summary collapse

Instance Method Details

#debug_writer=(proc) ⇒ Object

Raises:

  • (ArgumentError)


20
21
22
23
# File 'lib/cantango/config/debug.rb', line 20

def debug_writer= proc
  raise ArgumentError, "Debug writer must be callable (lambda or Proc), was: #{proc}" if !callable?(proc)
  @debug_writer = proc
end

#off?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/cantango/config/debug.rb', line 16

def off?
  !on?
end

#on?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/cantango/config/debug.rb', line 12

def on?
  @state == :on
end

#set(state = :on) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
# File 'lib/cantango/config/debug.rb', line 7

def set state = :on
  raise ArgumentError, "Must be :on or :off" unless !state || [:on, :off].include?(state)
  @state = state || :on
end

#write(msg) ⇒ Object



25
26
27
28
# File 'lib/cantango/config/debug.rb', line 25

def write msg
  @debug_writer ||= Proc.new{|msg| puts msg}
  @debug_writer.call(msg)
end