Sha256: f6d13bc6bf68304b3d8367e822c5e67284ae79836061af4f03c9122dbf10669b

Contents?: true

Size: 717 Bytes

Versions: 1

Compression:

Stored size: 717 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

1 entries across 1 versions & 1 rubygems

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