class Hanami::View::DecoratedAttributes::Attributes

@api private

Public Class Methods

new(*) click to toggle source
Calls superclass method
# File lib/hanami/view/decorated_attributes.rb, line 61
def initialize(*)
  @names = Set.new
  super
end

Public Instance Methods

decorate(*names, **options) click to toggle source
Calls superclass method
# File lib/hanami/view/decorated_attributes.rb, line 66
def decorate(*names, **options)
  @names += names

  class_eval do
    names.each do |name|
      define_method name do
        attribute = super()

        if _rendering && attribute
          _rendering.part(name, attribute, **options)
        else
          attribute
        end
      end
    end
  end
end
inspect() click to toggle source
# File lib/hanami/view/decorated_attributes.rb, line 84
def inspect
  %(#<#{self.class.name}#{@names.to_a.sort.inspect}>)
end