Sha256: c0c669c4314dd779c9488914817b3fbbfd394bc8402b8763a467bb27769c32b5

Contents?: true

Size: 525 Bytes

Versions: 3

Compression:

Stored size: 525 Bytes

Contents

module YARD
  module Templates
    module ErbCache
      def self.method_for(filename, &block)
        @methods ||= {}
        return @methods[filename] if @methods[filename]
        @methods[filename] = name = "_erb_cache_#{@methods.size}"
        erb = yield.src
        encoding = erb[/\A(#coding:.*\r?\n)/, 1] || ''
        module_eval "#{encoding}def #{name}; #{erb}; end", filename
        
        name
      end

      def self.clear!
        return unless @methods
        @methods.clear
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yard-0.5.8 lib/yard/templates/erb_cache.rb
yard-0.5.7 lib/yard/templates/erb_cache.rb
yard-0.5.6 lib/yard/templates/erb_cache.rb