Class: Proforma::HtmlRenderer::ObjectWriter
- Inherits:
-
Object
- Object
- Proforma::HtmlRenderer::ObjectWriter
- Defined in:
- lib/proforma/html_renderer/object_writer.rb
Overview
Each object should have its own ERB template. This class understands the connection of objects and templates and knows how to render the template for the respective object passed in.
Instance Attribute Summary collapse
-
#names_by_class ⇒ Object
readonly
Returns the value of attribute names_by_class.
-
#writer ⇒ Object
readonly
Returns the value of attribute writer.
Instance Method Summary collapse
-
#initialize(names_by_class: {}, writer: Writer.new) ⇒ ObjectWriter
constructor
A new instance of ObjectWriter.
- #render(object, options = {}) ⇒ Object
Constructor Details
#initialize(names_by_class: {}, writer: Writer.new) ⇒ ObjectWriter
Returns a new instance of ObjectWriter.
20 21 22 23 |
# File 'lib/proforma/html_renderer/object_writer.rb', line 20 def initialize(names_by_class: {}, writer: Writer.new) @names_by_class = names_by_class @writer = writer end |
Instance Attribute Details
#names_by_class ⇒ Object (readonly)
Returns the value of attribute names_by_class.
18 19 20 |
# File 'lib/proforma/html_renderer/object_writer.rb', line 18 def names_by_class @names_by_class end |
#writer ⇒ Object (readonly)
Returns the value of attribute writer.
18 19 20 |
# File 'lib/proforma/html_renderer/object_writer.rb', line 18 def writer @writer end |
Instance Method Details
#render(object, options = {}) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/proforma/html_renderer/object_writer.rb', line 25 def render(object, = {}) writer.render( resolve_name(object), object: object, options: ) end |