Class: LightSerializer::HashedObject

Inherits:
Object
  • Object
show all
Includes:
LightSerializer::Helpers::WithCustomRoot
Defined in:
lib/light_serializer/hashed_object.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LightSerializer::Helpers::WithCustomRoot

#with_custom_root

Constructor Details

#initialize(raw_object, serializer) ⇒ HashedObject

Returns a new instance of HashedObject.



13
14
15
16
# File 'lib/light_serializer/hashed_object.rb', line 13

def initialize(raw_object, serializer)
  @raw_object = raw_object
  @serializer = serializer
end

Instance Attribute Details

#raw_objectObject (readonly)

Returns the value of attribute raw_object.



7
8
9
# File 'lib/light_serializer/hashed_object.rb', line 7

def raw_object
  @raw_object
end

#serializerObject (readonly)

Returns the value of attribute serializer.



7
8
9
# File 'lib/light_serializer/hashed_object.rb', line 7

def serializer
  @serializer
end

Class Method Details

.get(*args) ⇒ Object



9
10
11
# File 'lib/light_serializer/hashed_object.rb', line 9

def self.get(*args)
  new(*args).get
end

Instance Method Details

#getObject



18
19
20
# File 'lib/light_serializer/hashed_object.rb', line 18

def get
  with_custom_root(serializer.root) { transform_to_hash(raw_object) }
end