Class: Hanami::View::Context Abstract

Inherits:
Object
  • Object
show all
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.

Since:

  • 2.1.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DecoratedAttributes

included

Constructor Details

#initializeContext

Returns a new instance of Context

Since:

  • 2.1.0



33
34
# File 'lib/hanami/view/context.rb', line 33

def initialize(**)
end

Instance Attribute Details

#_renderingObject (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.

Since:

  • 2.1.0



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.

Since:

  • 2.1.0



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.

Since:

  • 2.1.0



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