Module: Serega::SeregaObjectSerializer::InstanceMethods
- Included in:
- Serega::SeregaObjectSerializer
- Defined in:
- lib/serega/object_serializer.rb
Overview
SeregaObjectSerializer instance methods
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#many ⇒ Object
readonly
Returns the value of attribute many.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#points ⇒ Object
readonly
Returns the value of attribute points.
Instance Method Summary collapse
-
#initialize(context:, points:, many: nil, **opts) ⇒ SeregaObjectSerializer
New SeregaObjectSerializer.
-
#serialize(object) ⇒ Hash+
Serializes object(s).
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
13 14 15 |
# File 'lib/serega/object_serializer.rb', line 13 def context @context end |
#many ⇒ Object (readonly)
Returns the value of attribute many.
13 14 15 |
# File 'lib/serega/object_serializer.rb', line 13 def many @many end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
13 14 15 |
# File 'lib/serega/object_serializer.rb', line 13 def opts @opts end |
#points ⇒ Object (readonly)
Returns the value of attribute points.
13 14 15 |
# File 'lib/serega/object_serializer.rb', line 13 def points @points end |
Instance Method Details
#initialize(context:, points:, many: nil, **opts) ⇒ SeregaObjectSerializer
Returns New SeregaObjectSerializer.
20 21 22 23 24 25 |
# File 'lib/serega/object_serializer.rb', line 20 def initialize(context:, points:, many: nil, **opts) @context = context @points = points @many = many @opts = opts end |
#serialize(object) ⇒ Hash+
Serializes object(s)
32 33 34 35 36 |
# File 'lib/serega/object_serializer.rb', line 32 def serialize(object) return if object.nil? array?(object, many) ? serialize_array(object) : serialize_object(object) end |