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.4.10 lib/remnant/template.rb
remnant-0.4.9 lib/remnant/template.rb
remnant-0.4.8 lib/remnant/template.rb
remnant-0.4.7 lib/remnant/template.rb
remnant-0.4.6 lib/remnant/template.rb
remnant-0.4.5 lib/remnant/template.rb
remnant-0.9.5 lib/remnant/template.rb
remnant-0.9.4 lib/remnant/template.rb
remnant-0.4.4 lib/remnant/template.rb
remnant-0.9.3 lib/remnant/template.rb
remnant-0.9.2 lib/remnant/template.rb
remnant-0.9.1 lib/remnant/template.rb
remnant-0.9.0 lib/remnant/template.rb
remnant-0.4.3 lib/remnant/template.rb
remnant-0.4.2 lib/remnant/template.rb
remnant-0.4.1 lib/remnant/template.rb
remnant-0.4.0 lib/remnant/template.rb
remnant-0.3.3 lib/remnant/template.rb
remnant-0.3.2 lib/remnant/template.rb
remnant-0.3.1 lib/remnant/template.rb