Module: Hanami::View::DecoratedAttributes::ClassInterface

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

Overview

Decorated attributes class-level interface.

Since:

  • 2.1.0

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.

Since:

  • 2.1.0

: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 < Hanami::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

Since:

  • 2.1.0



42
43
44
# File 'lib/hanami/view/decorated_attributes.rb', line 42

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