Class: Dry::View::RenderEnvironment Private

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/view/render_environment.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(renderer:, inflector:, context:, scope_builder:, part_builder:) ⇒ RenderEnvironment

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.

Returns a new instance of RenderEnvironment.



23
24
25
26
27
28
29
# File 'lib/dry/view/render_environment.rb', line 23

def initialize(renderer:, inflector:, context:, scope_builder:, part_builder:)
  @renderer = renderer
  @inflector = inflector
  @context = context.for_render_env(self)
  @scope_builder = scope_builder.for_render_env(self)
  @part_builder = part_builder.for_render_env(self)
end

Instance Attribute Details

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



21
22
23
# File 'lib/dry/view/render_environment.rb', line 21

def context
  @context
end

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



21
22
23
# File 'lib/dry/view/render_environment.rb', line 21

def inflector
  @inflector
end

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



21
22
23
# File 'lib/dry/view/render_environment.rb', line 21

def part_builder
  @part_builder
end

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



21
22
23
# File 'lib/dry/view/render_environment.rb', line 21

def renderer
  @renderer
end

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



21
22
23
# File 'lib/dry/view/render_environment.rb', line 21

def scope_builder
  @scope_builder
end

Class Method Details

.prepare(renderer, config, context) ⇒ 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.



9
10
11
12
13
14
15
16
17
# File 'lib/dry/view/render_environment.rb', line 9

def self.prepare(renderer, config, context)
  new(
    renderer: renderer,
    inflector: config.inflector,
    context: context,
    scope_builder: config.scope_builder.new(namespace: config.scope_namespace),
    part_builder: config.part_builder.new(namespace: config.part_namespace)
  )
end

Instance Method Details

#chdir(dirname) ⇒ 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.



51
52
53
54
55
56
57
58
59
# File 'lib/dry/view/render_environment.rb', line 51

def chdir(dirname)
  self.class.new(
    renderer: renderer.chdir(dirname),
    inflector: inflector,
    context: context,
    scope_builder: scope_builder,
    part_builder: part_builder
  )
end

#formatObject

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.



31
32
33
# File 'lib/dry/view/render_environment.rb', line 31

def format
  renderer.format
end

#part(name, value, **options) ⇒ 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.



35
36
37
# File 'lib/dry/view/render_environment.rb', line 35

def part(name, value, **options)
  part_builder.(name, value, **options)
end

#partial(name, scope, &block) ⇒ 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.



47
48
49
# File 'lib/dry/view/render_environment.rb', line 47

def partial(name, scope, &block)
  renderer.partial(name, scope, &block)
end

#scope(name = nil, locals) ⇒ 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.

rubocop:disable Style/OptionalArguments



39
40
41
# File 'lib/dry/view/render_environment.rb', line 39

def scope(name = nil, locals) # rubocop:disable Style/OptionalArguments
  scope_builder.(name, locals)
end

#template(name, scope, &block) ⇒ 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.



43
44
45
# File 'lib/dry/view/render_environment.rb', line 43

def template(name, scope, &block)
  renderer.template(name, scope, &block)
end