Module: Amrita::CacheManager

Module Amrita::CacheManager |
In: | lib/amrita/template.rb

Methods

cache valid_item?

Public Instance methods

cache(filename, typ, source_mtime=nil, key=nil, &block) {|| ...}

    # File lib/amrita/template.rb, line 12
        def cache(filename, typ, source_mtime=nil, key=nil, &block)
          source_mtime = Time.new unless source_mtime
          item = get_item(typ, filename, key) || Item.new
          unless valid_item?(item, source_mtime)
            item.filename = filename
            item.type = typ
            item.key = key
            item.mtime = source_mtime
            item.contents = yield
            save_item(item)
          end
          item.contents
        end

valid_item?(item, source_mtime)

    # File lib/amrita/template.rb, line 26
        def valid_item?(item, source_mtime)
          item.mtime && source_mtime && item.mtime >= source_mtime
        end