Module: Serega::SeregaObjectSerializer::SeregaObjectSerializerInstanceMethods

Included in:
Serega::SeregaObjectSerializer
Defined in:
lib/serega/object_serializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/serega/object_serializer.rb', line 6

def context
  @context
end

#manyObject (readonly)

Returns the value of attribute many.



6
7
8
# File 'lib/serega/object_serializer.rb', line 6

def many
  @many
end

#optsObject (readonly)

Returns the value of attribute opts.



6
7
8
# File 'lib/serega/object_serializer.rb', line 6

def opts
  @opts
end

#pointsObject (readonly)

Returns the value of attribute points.



6
7
8
# File 'lib/serega/object_serializer.rb', line 6

def points
  @points
end

Instance Method Details

#initialize(context:, points:, many: nil, **opts) ⇒ Object

Parameters:

  • context (Hash)

    Serialization context

  • many (TrueClass|FalseClass) (defaults to: nil)

    is object is enumerable

  • points (Array<MapPoint>)

    Serialization points (attributes)



11
12
13
14
15
16
# File 'lib/serega/object_serializer.rb', line 11

def initialize(context:, points:, many: nil, **opts)
  @context = context
  @points = points
  @many = many
  @opts = opts
end

#serialize(object) ⇒ Object

Parameters:

  • object (Object)

    Serialized object



19
20
21
# File 'lib/serega/object_serializer.rb', line 19

def serialize(object)
  array?(object, many) ? serialize_array(object) : serialize_object(object)
end