Module: Serega::SeregaObjectSerializer::InstanceMethods
- Included in:
- Serega::SeregaObjectSerializer
- Defined in:
- lib/serega/object_serializer.rb
Overview
SeregaObjectSerializer instance methods
Instance Attribute Summary collapse
-
#batch_loaders ⇒ Object
readonly
Returns the value of attribute batch_loaders.
-
#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.
-
#plan ⇒ Object
readonly
Returns the value of attribute plan.
Instance Method Summary collapse
-
#initialize(context:, plan:, many: nil, **opts) ⇒ SeregaObjectSerializer
New SeregaObjectSerializer.
-
#serialize(object) ⇒ Hash, ...
Serializes object(s).
Instance Attribute Details
#batch_loaders ⇒ Object (readonly)
Returns the value of attribute batch_loaders.
13 14 15 |
# File 'lib/serega/object_serializer.rb', line 13 def batch_loaders @batch_loaders end |
#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 |
#plan ⇒ Object (readonly)
Returns the value of attribute plan.
13 14 15 |
# File 'lib/serega/object_serializer.rb', line 13 def plan @plan end |
Instance Method Details
#initialize(context:, plan:, many: nil, **opts) ⇒ SeregaObjectSerializer
Returns New SeregaObjectSerializer.
21 22 23 24 25 26 27 |
# File 'lib/serega/object_serializer.rb', line 21 def initialize(context:, plan:, many: nil, **opts) @context = context @plan = plan @many = many @opts = opts @batch_loaders = opts[:batch_loaders] end |
#serialize(object) ⇒ Hash, ...
Serializes object(s)
34 35 36 37 38 |
# File 'lib/serega/object_serializer.rb', line 34 def serialize(object) return if object.nil? array?(object, many) ? serialize_array(object) : serialize_object(object) end |