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 Method Summary collapse
-
#initialize(key_transformation: :none, &block) ⇒ NestedAttribute
constructor
private
A new instance of NestedAttribute.
-
#value(object:, params:) ⇒ 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.
7 8 9 10 |
# File 'lib/alba/nested_attribute.rb', line 7 def initialize(key_transformation: :none, &block) @key_transformation = key_transformation @block = block end |
Instance Method Details
#value(object:, params:) ⇒ 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.
15 16 17 18 19 20 |
# File 'lib/alba/nested_attribute.rb', line 15 def value(object:, params:) resource_class = Alba.resource_class resource_class.transform_keys(@key_transformation) resource_class.class_eval(&@block) resource_class.new(object, params: params).serializable_hash end |