Class: Hypernova::BatchRenderer
- Inherits:
-
Object
- Object
- Hypernova::BatchRenderer
- Includes:
- PluginHelper
- Defined in:
- lib/hypernova/batch_renderer.rb
Instance Method Summary collapse
-
#initialize(jobs) ⇒ BatchRenderer
constructor
A new instance of BatchRenderer.
-
#render(response) ⇒ Object
Example of what is returned by this method: { “DeathStarLaserComponent.js” => “<h1>Hello World</h1>”, “IonCannon.js” => <p>Feel my power!</p>, }.
-
#render_blank ⇒ Object
Example of what is returned by this method: { “DeathStarLaserComponent.js” => <div>I am blank</div>, “IonCannon.js” => <div>I am blank</div>, }.
Methods included from PluginHelper
#after_response, #get_view_data, #on_error, #on_success, #prepare_request, #send_request?, #will_send_request
Constructor Details
#initialize(jobs) ⇒ BatchRenderer
Returns a new instance of BatchRenderer.
7 8 9 |
# File 'lib/hypernova/batch_renderer.rb', line 7 def initialize(jobs) @jobs = jobs end |
Instance Method Details
#render(response) ⇒ Object
Example of what is returned by this method:
"DeathStarLaserComponent.js" => "<h1>Hello World</h1>",
"IonCannon.js" => <p>Feel my power!</p>,
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/hypernova/batch_renderer.rb', line 39 def render(response) fmt_response = response.each_with_object({}) do |array, hash| name_of_component = array[0] hash[name_of_component] = ensure_has_html(name_of_component, array[1]) end after_response(fmt_response, response).each_with_object({}) do |(name, result), hash| hash[name] = result['html'] end end |
#render_blank ⇒ Object
Example of what is returned by this method:
"DeathStarLaserComponent.js" => <div>I am blank</div>,
"IonCannon.js" => <div>I am blank</div>,
55 56 57 58 59 |
# File 'lib/hypernova/batch_renderer.rb', line 55 def render_blank hash = {} jobs.each { |name_of_component, job| hash[name_of_component] = render_blank_html(job) } hash end |