Class: LiveCable::Rendering::RenderResult
- Inherits:
-
Object
- Object
- LiveCable::Rendering::RenderResult
- Defined in:
- lib/live_cable/rendering/render_result.rb
Instance Attribute Summary collapse
- #child_results ⇒ Hash<String, RenderResult>
- #live_id ⇒ String readonly
- #parts ⇒ Array<String, nil> readonly
- #template_hash ⇒ String readonly
Instance Method Summary collapse
- #as_json ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(live_id, parts, template_path) ⇒ RenderResult
constructor
A new instance of RenderResult.
Constructor Details
#initialize(live_id, parts, template_path) ⇒ RenderResult
Returns a new instance of RenderResult.
18 19 20 21 22 23 |
# File 'lib/live_cable/rendering/render_result.rb', line 18 def initialize(live_id, parts, template_path) @live_id = live_id @parts = parts @template_hash = Digest::SHA256.hexdigest(template_path)[0..11] @child_results = {} end |
Instance Attribute Details
#child_results ⇒ Hash<String, RenderResult>
16 17 18 |
# File 'lib/live_cable/rendering/render_result.rb', line 16 def child_results @child_results end |
#live_id ⇒ String (readonly)
7 8 9 |
# File 'lib/live_cable/rendering/render_result.rb', line 7 def live_id @live_id end |
#parts ⇒ Array<String, nil> (readonly)
10 11 12 |
# File 'lib/live_cable/rendering/render_result.rb', line 10 def parts @parts end |
#template_hash ⇒ String (readonly)
13 14 15 |
# File 'lib/live_cable/rendering/render_result.rb', line 13 def template_hash @template_hash end |
Instance Method Details
#as_json ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/live_cable/rendering/render_result.rb', line 29 def as_json { h: template_hash, p: parts, c: child_results.reject { |_k, v| v.empty? }.as_json, }.compact_blank end |
#empty? ⇒ Boolean
25 26 27 |
# File 'lib/live_cable/rendering/render_result.rb', line 25 def empty? parts.compact.empty? end |