Sha256: 6982841bfcc2132b77ffd5946eea6cba688f347d677f291aeac7a68a17e80535
Contents?: true
Size: 1.17 KB
Versions: 4
Compression:
Stored size: 1.17 KB
Contents
require 'aldous/respondable/base' require 'aldous/respondable/shared/flash' module Aldous module Respondable class Renderable < Base def action(controller) RenderAction.new(template, status, controller, view_data) end def default_status :ok end def default_template_locals {} end def template_data {} end def template(extra_locals = {}) template_locals = template_data[:locals] || {} locals = default_template_locals.merge(template_locals) locals = locals.merge(extra_locals || {}) template_hash = template_data.merge(locals: locals) template_hash end private class RenderAction attr_reader :template, :controller, :view_data, :status def initialize(template, status, controller, view_data) @status = status @template = template @controller = controller @view_data = view_data end def execute Shared::Flash.new(view_data, controller.flash.now).set_error controller.render template.merge(status: status) end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems