module Dry::View::DecoratedAttributes::ClassInterface

Decorated attributes class-level interface.

Constants

MODULE_NAME

@api private

Public Instance Methods

decorate(*names, **options) click to toggle source

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

@example

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

@param names [Array<Symbol>] the attribute names @param options [Hash] the options to pass to the Part Builder @option options [Symbol, Class] :as an alternative name or class to use when finding a

matching Part

@api public

# File lib/dry/view/decorated_attributes.rb, line 34
def decorate(*names, **options)
  decorated_attributes.decorate(*names, **options)
end

Private Instance Methods

decorated_attributes() click to toggle source
# File lib/dry/view/decorated_attributes.rb, line 40
def decorated_attributes
  if const_defined?(MODULE_NAME, false)
    const_get(MODULE_NAME)
  else
    const_set(MODULE_NAME, Attributes.new).tap do |mod|
      prepend mod
    end
  end
end