class Cynic::Renderer
Public Class Methods
new(path, controller=nil)
click to toggle source
# File lib/cynic/renderer.rb, line 3 def initialize(path, controller=nil) controller.instance_variables.each do |method| self.instance_variable_set(method, controller.instance_variable_get(method)) end @full_path = path_prefix + path @layout = path_prefix + "layouts/application.html.erb" end
Public Instance Methods
body()
click to toggle source
# File lib/cynic/renderer.rb, line 13 def body layout { ERB.new(File.read(@full_path)).result(binding) } end
layout()
click to toggle source
# File lib/cynic/renderer.rb, line 17 def layout ERB.new(layout_file || "<%= yield %>").result(binding) end
layout_exists?()
click to toggle source
# File lib/cynic/renderer.rb, line 29 def layout_exists? File.exists? @layout end
layout_file()
click to toggle source
# File lib/cynic/renderer.rb, line 21 def layout_file layout_exists? ? File.read(@layout) : "<%= yield %>" end
path_prefix()
click to toggle source
# File lib/cynic/renderer.rb, line 25 def path_prefix "app/views/" end