lib/ruby_app/mixins/render_mixin.rb in RubyApp-0.0.88 vs lib/ruby_app/mixins/render_mixin.rb in RubyApp-0.0.89
- old
+ new
@@ -6,11 +6,10 @@
module RubyApp
module Mixins
module RenderMixin
- require 'ruby_app/log'
require 'ruby_app/request'
def rendered?(template)
unless RubyApp::Request.rendered?(template)
yield
@@ -24,11 +23,10 @@
def render(format, write_cache = false)
cache = self.is_a?(Class) ? self.get_cache(format) : self.class.get_cache(format)
if File.exists?(cache)
self.rendered?(cache) do
- RubyApp::Log.debug("#{RubyApp::Log.prefix(self, __method__)} File.read(#{cache.inspect})")
return File.read(cache)
end
else
templates = self.is_a?(Class) ? self.get_templates(format) : self.class.get_templates(format)
unless templates.empty?
@@ -49,10 +47,9 @@
end
end
RubyApp::Request.content_for(self, template, content)
end
if cache && write_cache
- RubyApp::Log.debug("#{RubyApp::Log.prefix(self, __method__)} File.open(#{cache.inspect}, 'w')")
cache_directory = File.dirname(cache)
Dir.mkdir(cache_directory) unless File.exists?(cache_directory)
File.open(cache, 'w') do |file|
file.write(RubyApp::Request.get_content(self, templates.last))
file.flush