lib/defined.rb in defined-0.0.1 vs lib/defined.rb in defined-0.0.2

- old
+ new

@@ -1,14 +1,24 @@ # Calls <tt>Module#defined(file, line, method)</tt> after a class or module has been defined or redefined module Defined autoload :Version, 'defined/version' class << self - def included(mod) # :nodoc: + def disable! + set_trace_func nil + @enabled = false + end + + def enable! set_trace_func method(:trace_function).to_proc + @enabled = true end + def enabled? + @enabled ||= false + end + # An array of classes and modules that are currently being defined def definitions @definitions ||= [] end @@ -43,8 +53,6 @@ method ||= object.class.name.downcase.to_sym object.defined(file, line, method) if object.respond_to?(:defined) end end end -end - -Module.send(:include, Defined) +end \ No newline at end of file