Class: Errgent::Renderer
- Inherits:
-
Object
- Object
- Errgent::Renderer
- Defined in:
- lib/errgent/renderer.rb
Instance Method Summary collapse
- #helpers(&block) ⇒ Object
-
#initialize(options = {}) ⇒ Renderer
constructor
A new instance of Renderer.
- #render ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Renderer
Returns a new instance of Renderer.
2 3 4 5 6 7 |
# File 'lib/errgent/renderer.rb', line 2 def initialize( = {}) @vars = [:vars] || {} @codes = [:codes] || [403, 404, 422, 500] @layout = [:layout] || 'layouts/error_page' @output = [:output] || 'public/%s.html' end |
Instance Method Details
#helpers(&block) ⇒ Object
18 19 20 |
# File 'lib/errgent/renderer.rb', line 18 def helpers(&block) action_view.class_eval(&block) end |
#render ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/errgent/renderer.rb', line 9 def render @codes.each do |code| File.open(Rails.root.join(@output % code), 'w') do |io| action_view.assign(@vars.merge(code: code)) io.write action_view.render(template: @layout) end end end |