Class: Dry::View::DecoratedAttributes::Attributes Private

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

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.

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.



53
54
55
56
# File 'lib/dry/view/decorated_attributes.rb', line 53

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.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/dry/view/decorated_attributes.rb', line 58

def decorate(*names, **options)
  @names += names

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

        if _render_env && attribute
          _render_env.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.



76
77
78
# File 'lib/dry/view/decorated_attributes.rb', line 76

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