Class: Hanami::Utils::ClassAttribute::Attributes Private
- Inherits:
-
Object
- Object
- Hanami::Utils::ClassAttribute::Attributes
- Defined in:
- lib/hanami/utils/class_attribute/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.
Class attributes set
Instance Method Summary collapse
- #[](key) ⇒ Object private
- #[]=(key, value) ⇒ Object private
- #dup ⇒ Object private
-
#initialize(attributes: Concurrent::Map.new) ⇒ Attributes
constructor
private
A new instance of Attributes.
Constructor Details
#initialize(attributes: Concurrent::Map.new) ⇒ Attributes
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.
15 16 17 |
# File 'lib/hanami/utils/class_attribute/attributes.rb', line 15 def initialize(attributes: Concurrent::Map.new) @attributes = attributes end |
Instance Method Details
#[](key) ⇒ 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.
27 28 29 |
# File 'lib/hanami/utils/class_attribute/attributes.rb', line 27 def [](key) @attributes.fetch(key, nil) end |
#[]=(key, value) ⇒ 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.
21 22 23 |
# File 'lib/hanami/utils/class_attribute/attributes.rb', line 21 def []=(key, value) @attributes[key.to_sym] = value end |
#dup ⇒ 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.
33 34 35 36 37 38 39 40 41 |
# File 'lib/hanami/utils/class_attribute/attributes.rb', line 33 def dup attributes = Concurrent::Map.new.tap do |attrs| @attributes.each do |key, value| attrs[key.to_sym] = value.dup end end self.class.new(attributes: attributes) end |