Class: Prototok::Serializers::Attribute
- Inherits:
-
Object
- Object
- Prototok::Serializers::Attribute
- Defined in:
- lib/prototok/attribute.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#serializer ⇒ Object
readonly
Returns the value of attribute serializer.
Instance Method Summary collapse
-
#initialize(options) ⇒ Attribute
constructor
A new instance of Attribute.
- #serialize(value) ⇒ Object
Constructor Details
#initialize(options) ⇒ Attribute
Returns a new instance of Attribute.
7 8 9 10 |
# File 'lib/prototok/attribute.rb', line 7 def initialize() @options = || {} @serializer = Serializers.find(@options[:serializer]) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/prototok/attribute.rb', line 4 def @options end |
#serializer ⇒ Object (readonly)
Returns the value of attribute serializer.
5 6 7 |
# File 'lib/prototok/attribute.rb', line 5 def serializer @serializer end |
Instance Method Details
#serialize(value) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/prototok/attribute.rb', line 12 def serialize(value) if @serializer @serializer.new(value).encode else value end end |