lib/peekaboo/configuration.rb in peekaboo-0.1.2 vs lib/peekaboo/configuration.rb in peekaboo-0.2.0

- old
+ new

@@ -1,10 +1,34 @@ require 'logger' +require 'set' module Peekaboo + # Rome wasn't built in a day... + # Documentation soon to come. class Configuration TRACE_LEVELS = [ :debug, :info, :warn, :error, :fatal, :unknown ] + + def initialize + @autoincluded = Set.new + end + + def autoincluded + @autoincluded.to_a + end + + 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 def tracer @tracer ||= Logger.new STDOUT end