Class: Komponent::ComponentRenderer
- Inherits:
-
Object
- Object
- Komponent::ComponentRenderer
- Includes:
- ActionView::Helpers::CaptureHelper
- Defined in:
- lib/komponent/component_renderer.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
Instance Method Summary collapse
-
#initialize(controller) ⇒ ComponentRenderer
constructor
A new instance of ComponentRenderer.
- #render(component, locals = {}, options = {}, &block) ⇒ Object
Constructor Details
#initialize(controller) ⇒ ComponentRenderer
Returns a new instance of ComponentRenderer.
10 11 12 13 14 |
# File 'lib/komponent/component_renderer.rb', line 10 def initialize(controller) @context = controller.view_context.dup @view_renderer = @context.view_renderer = @context.view_renderer.dup @lookup_context = @view_renderer.lookup_context = @view_renderer.lookup_context.dup end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
8 9 10 |
# File 'lib/komponent/component_renderer.rb', line 8 def context @context end |
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
7 8 9 |
# File 'lib/komponent/component_renderer.rb', line 7 def output_buffer @output_buffer end |
Instance Method Details
#render(component, locals = {}, options = {}, &block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/komponent/component_renderer.rb', line 16 def render(component, locals = {}, = {}, &block) cached = .delete(:cached) if cached cached_block = block ? block.call : nil key = [component, locals, , cached_block].to_s cache_key = Digest::SHA1.hexdigest(key) Rails.cache.fetch(cache_key) do _render(component, locals, , &block) end else _render(component, locals, , &block) end end |