Class: Alba::NestedAttribute Private
- Inherits:
-
Object
- Object
- Alba::NestedAttribute
- Defined in:
- lib/alba/nested_attribute.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.
Representing nested attribute
Instance Attribute Summary collapse
-
#key_transformation ⇒ Object
writeonly
private
Setter for key_transformation, used when it’s changed after class definition.
Instance Method Summary collapse
-
#initialize(key_transformation: :none, &block) ⇒ NestedAttribute
constructor
private
A new instance of NestedAttribute.
-
#value(object:, params:, within:) ⇒ Hash
private
Hash serialized from running the class body in the object.
Constructor Details
#initialize(key_transformation: :none, &block) ⇒ NestedAttribute
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 NestedAttribute.
12 13 14 15 |
# File 'lib/alba/nested_attribute.rb', line 12 def initialize(key_transformation: :none, &block) @key_transformation = key_transformation @block = block end |
Instance Attribute Details
#key_transformation=(value) ⇒ Object (writeonly)
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.
Setter for key_transformation, used when it’s changed after class definition
8 9 10 |
# File 'lib/alba/nested_attribute.rb', line 8 def key_transformation=(value) @key_transformation = value end |
Instance Method Details
#value(object:, params:, within:) ⇒ Hash
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 hash serialized from running the class body in the object.
21 22 23 24 25 26 |
# File 'lib/alba/nested_attribute.rb', line 21 def value(object:, params:, within:) resource_class = Alba.resource_class resource_class.transform_keys(@key_transformation) resource_class.class_eval(&@block) resource_class.new(object, params: params, within: within).serializable_hash end |