Class: Hanami::View::DecoratedAttributes::Attributes Private

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

Overview

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

Since:

  • 2.1.0

Instance Method Summary collapse

Constructor Details

#initializeAttributes

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

Returns a new instance of Attributes.

Since:

  • 2.1.0



61
62
63
64
# File 'lib/hanami/view/decorated_attributes.rb', line 61

def initialize(*)
  @names = Set.new
  super
end

Instance Method Details

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

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

Since:

  • 2.1.0



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# 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

#inspectObject

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

Since:

  • 2.1.0



84
85
86
# File 'lib/hanami/view/decorated_attributes.rb', line 84

def inspect
  %(#<#{self.class.name}#{@names.to_a.sort.inspect}>)
end