Class: Cuprum::Rails::Serializers::Json::PropertiesSerializer::SerializedProperty

Inherits:
Struct
  • Object
show all
Defined in:
lib/cuprum/rails/serializers/json/properties_serializer.rb

Overview

Data class that configures how an attribute is serialized.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mappingObject

Returns the value of attribute mapping

Returns:

  • (Object)

    the current value of mapping



86
87
88
# File 'lib/cuprum/rails/serializers/json/properties_serializer.rb', line 86

def mapping
  @mapping
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



86
87
88
# File 'lib/cuprum/rails/serializers/json/properties_serializer.rb', line 86

def name
  @name
end

#scopeObject

Returns the value of attribute scope

Returns:

  • (Object)

    the current value of scope



86
87
88
# File 'lib/cuprum/rails/serializers/json/properties_serializer.rb', line 86

def scope
  @scope
end

#serializerObject

Returns the value of attribute serializer

Returns:

  • (Object)

    the current value of serializer



86
87
88
# File 'lib/cuprum/rails/serializers/json/properties_serializer.rb', line 86

def serializer
  @serializer
end

Instance Method Details

#value_for(object) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Extracts the scoped value from the given object.



91
92
93
94
95
96
97
98
99
100
# File 'lib/cuprum/rails/serializers/json/properties_serializer.rb', line 91

def value_for(object)
  return object if scope.nil?

  return object.dig(*Array(scope)) if object.respond_to?(:dig)

  SleepingKingStudios::Tools::Toolbelt
    .instance
    .object_tools
    .dig(object, *Array(scope))
end