Class: Dry::View::PartBuilder Private

Inherits:
Object
  • Object
show all
Extended by:
Core::Cache
Defined in:
lib/dry/view/part_builder.rb

Overview

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.

Decorates exposure values with matching parts

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace: nil, render_env: nil) ⇒ PartBuilder

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 PartBuilder



22
23
24
25
# File 'lib/dry/view/part_builder.rb', line 22

def initialize(namespace: nil, render_env: nil)
  @namespace = namespace
  @render_env = render_env
end

Instance Attribute Details

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



16
17
18
# File 'lib/dry/view/part_builder.rb', line 16

def namespace
  @namespace
end

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



17
18
19
# File 'lib/dry/view/part_builder.rb', line 17

def render_env
  @render_env
end

Instance Method Details

#call(name, value, **options) ⇒ Dry::View::Part

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.

Decorates an exposure value

Parameters:

  • name (Symbol)

    exposure name

  • value (Object)

    exposure value

  • options (Hash)

    exposure options

Returns:



43
44
45
46
47
# File 'lib/dry/view/part_builder.rb', line 43

def call(name, value, **options)
  builder = value.respond_to?(:to_ary) ? :build_collection_part : :build_part

  send(builder, name, value, **options)
end

#for_render_env(render_env) ⇒ 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.



28
29
30
31
32
# File 'lib/dry/view/part_builder.rb', line 28

def for_render_env(render_env)
  return self if render_env == self.render_env

  self.class.new(namespace: namespace, render_env: render_env)
end