Class: Peekaboo::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/peekaboo/configuration.rb

Overview

Rome wasn’t built in a day… Documentation soon to come.

Constant Summary collapse

TRACE_LEVELS =
[ :debug, :info, :warn, :error, :fatal, :unknown ]

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
# File 'lib/peekaboo/configuration.rb', line 11

def initialize
  @autoincluded = Set.new
end

Instance Method Details

#autoinclude_with(*klasses) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/peekaboo/configuration.rb', line 19

def autoinclude_with *klasses
  if klasses.all? { |klass| klass.instance_of? Class }
    @autoincluded.merge klasses
    
    autoincluded.each do |klass|
      next if klass.included_modules.include? Peekaboo.to_s
      Peekaboo.setup_autoinclusion klass
    end
  else
    raise 'Auto-inclusion can only be used with classes'
  end
end

#autoincludedObject



15
16
17
# File 'lib/peekaboo/configuration.rb', line 15

def autoincluded
  @autoincluded.to_a
end

#trace_with(tracer) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/peekaboo/configuration.rb', line 36

def trace_with tracer
  if TRACE_LEVELS.all? { |level| tracer.respond_to? level }
    @tracer = tracer
  else
    raise 'Tracer must respond to debug(), info(), warn(), error(), fatal(), and unknown()'
  end
end

#tracerObject



32
33
34
# File 'lib/peekaboo/configuration.rb', line 32

def tracer
  @tracer ||= Logger.new STDOUT
end