Module: Dry::View::DecoratedAttributes::ClassInterface

Defined in:
lib/dry/view/decorated_attributes.rb

Overview

Decorated attributes class-level interface.

Constant Summary collapse

MODULE_NAME =

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

:DecoratedAttributes

Instance Method Summary collapse

Instance Method Details

#decorate(*names, **options) ⇒ Object

Decorates the provided attributes, wrapping them in Parts using the current render environment.

Examples:

class Article < Dry::View::Part
  decorate :feature_image
  decorate :author as: :person
end

Parameters:

  • names (Array<Symbol>)

    the attribute names

  • options (Hash)

    the options to pass to the Part Builder

Options Hash (**options):

  • :as (Symbol, Class)

    an alternative name or class to use when finding a matching Part



34
35
36
# File 'lib/dry/view/decorated_attributes.rb', line 34

def decorate(*names, **options)
  decorated_attributes.decorate(*names, **options)
end