class SemiStatic::Backend

Public Class Methods

new(root) click to toggle source
# File lib/semi_static/backend.rb, line 4
def initialize(root)
  @root = root
  @cache = {}
end

Public Instance Methods

all(page_type) click to toggle source
# File lib/semi_static/backend.rb, line 9
def all(page_type)
  if !@cache.key?(page_type) || !Rails.application.config.cache_classes
    path = File.join(@root,ActiveModel::Naming.plural(page_type), "*")
    @cache[page_type] = Dir.glob(path).map do |f|
      yaml, body = File.read(f).split("\n...\n", 2)
      h = YAML.load(yaml)
      page_type.new(SemiStatic::TiltWrapper.template(f,body), h)
    end
  end
  @cache[page_type]
end