Class: Eazypi::Serializer::Attribute
- Inherits:
-
Object
- Object
- Eazypi::Serializer::Attribute
- Defined in:
- lib/eazypi/serializer.rb
Overview
Defines an Attribute on a serializer
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, type:, required:, method:, method_name:) ⇒ Attribute
constructor
A new instance of Attribute.
- #serialize(object) ⇒ Object
Constructor Details
#initialize(name, type:, required:, method:, method_name:) ⇒ Attribute
Returns a new instance of Attribute.
12 13 14 15 16 17 18 |
# File 'lib/eazypi/serializer.rb', line 12 def initialize(name, type:, required:, method:, method_name:) @name = name @type = type @method = method @method_name = method_name @required = required end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/eazypi/serializer.rb', line 10 def name @name end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
10 11 12 |
# File 'lib/eazypi/serializer.rb', line 10 def required @required end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/eazypi/serializer.rb', line 10 def type @type end |
Instance Method Details
#serialize(object) ⇒ Object
20 21 22 23 24 |
# File 'lib/eazypi/serializer.rb', line 20 def serialize(object) the_value = value(object) Serializer.serialize_object(type, the_value) end |