Class: Hanami::View::PartBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/view/part_builder.rb

Overview

Decorates exposure values with matching parts.

Since:

  • 2.1.0

Class Method Summary collapse

Class Method Details

.call(name, value, as: nil, rendering:) ⇒ Hanami::View::Part

Decorates an exposure value.

Parameters:

  • name (Symbol)

    exposure name

  • value (Object)

    exposure value

  • as (Symbol, nil) (defaults to: nil)

    alternative name to use for part class resolution

Returns:

Since:

  • 2.1.0



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

def call(name, value, as: nil, rendering:)
  builder = value.respond_to?(:to_ary) ? :build_collection_part : :build_part

  send(builder, name: name, value: value, as: as, rendering: rendering)
end