Class: Aldous::Respondable::Renderable

Inherits:
Base
  • Object
show all
Defined in:
lib/aldous/respondable/renderable.rb

Defined Under Namespace

Classes: RenderAction

Instance Attribute Summary

Attributes inherited from Base

#view_context, #view_data

Instance Method Summary collapse

Methods inherited from Base

#build_view, #initialize, #status

Constructor Details

This class inherits a constructor from Aldous::Respondable::Base

Instance Method Details

#action(controller) ⇒ Object



7
8
9
# File 'lib/aldous/respondable/renderable.rb', line 7

def action(controller)
  RenderAction.new(template, status, controller, view_data)
end

#default_statusObject



11
12
13
# File 'lib/aldous/respondable/renderable.rb', line 11

def default_status
  :ok
end

#default_template_localsObject



15
16
17
# File 'lib/aldous/respondable/renderable.rb', line 15

def default_template_locals
  {}
end

#template(extra_locals = {}) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/aldous/respondable/renderable.rb', line 23

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

#template_dataObject



19
20
21
# File 'lib/aldous/respondable/renderable.rb', line 19

def template_data
  {}
end