Sha256: 1233bbc11dcc57bfd80c2ff15ff1c65212404f08e3096866070f40dda97e5665

Contents?: true

Size: 715 Bytes

Versions: 21

Compression:

Stored size: 715 Bytes

Contents

class Remnant
  class Template

    module ClassMethods
      def disable!
        @enabled = false
      end

      def enable!
        @enabled = true
      end

      def enabled?
        @enabled
      end

      def record(template)
        return yield unless Remnant::Template.enabled?

        trace.start(template)
        begin
          result = yield
        ensure
          trace.finished(template)
        end
        return result
      end

      def reset
        Thread.current['remnant.template.trace'] = Remnant::Template::Trace.new
      end

      def trace
        Thread.current['remnant.template.trace'] ||= Remnant::Template::Trace.new
      end
    end
    extend ClassMethods
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
remnant-0.3.0 lib/remnant/template.rb