Class: Hanami::View::Context Abstract
- Includes:
- DecoratedAttributes
- Defined in:
- lib/hanami/view/context.rb
Overview
This class is abstract.
Subclass this and add your own methods (along with a custom ‘#initialize` if you wish to inject dependencies)
Provides a baseline environment across all the templates, parts and scopes in a given rendering.
Instance Attribute Summary collapse
- #_rendering ⇒ Object readonly private
Class Method Summary collapse
Instance Method Summary collapse
- #dup_for_rendering(rendering) ⇒ Object private
-
#initialize ⇒ Context
constructor
Returns a new instance of Context.
Methods included from DecoratedAttributes
Constructor Details
#initialize ⇒ Context
Returns a new instance of Context
33 34 |
# File 'lib/hanami/view/context.rb', line 33 def initialize(**) end |
Instance Attribute Details
#_rendering ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 |
# File 'lib/hanami/view/context.rb', line 18 def _rendering @_rendering end |
Class Method Details
.new(rendering: RenderingMissing.new, **args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 26 27 |
# File 'lib/hanami/view/context.rb', line 22 def self.new(rendering: RenderingMissing.new, **args) allocate.tap do |obj| obj.instance_variable_set(:@_rendering, rendering) obj.send(:initialize, **args) end end |
Instance Method Details
#dup_for_rendering(rendering) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
38 39 40 41 42 |
# File 'lib/hanami/view/context.rb', line 38 def dup_for_rendering(rendering) dup.tap do |obj| obj.instance_variable_set(:@_rendering, rendering) end end |