Class: AdequateSerialization::Attribute::Synthesized
- Inherits:
-
Object
- Object
- AdequateSerialization::Attribute::Synthesized
- Defined in:
- lib/adequate_serialization/attribute.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, &block) ⇒ Synthesized
constructor
A new instance of Synthesized.
- #serialize_to(serializer, response, model, _includes) ⇒ Object
Constructor Details
#initialize(name, &block) ⇒ Synthesized
Returns a new instance of Synthesized.
30 31 32 33 |
# File 'lib/adequate_serialization/attribute.rb', line 30 def initialize(name, &block) @name = name @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
28 29 30 |
# File 'lib/adequate_serialization/attribute.rb', line 28 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
28 29 30 |
# File 'lib/adequate_serialization/attribute.rb', line 28 def name @name end |
Instance Method Details
#serialize_to(serializer, response, model, _includes) ⇒ Object
35 36 37 38 |
# File 'lib/adequate_serialization/attribute.rb', line 35 def serialize_to(serializer, response, model, _includes) response[name] = AdequateSerialization.dump(serializer.instance_exec(model, &block)) end |