Class: PiResources::Serializer::HashSerializer

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/pi_resources/serializer/hash_serializer.rb

Direct Known Subclasses

SmartHashSerializer

Constant Summary

Constants included from Base

Base::TRANSFORMS_MAPPING

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

#as_json, #run_key_transform!, #to_h

Constructor Details

#initialize(resource, meta: nil, message: nil, context: nil, root: true) ⇒ HashSerializer

Returns a new instance of HashSerializer.



14
15
16
17
18
19
20
21
# File 'lib/pi_resources/serializer/hash_serializer.rb', line 14

def initialize(resource, meta: nil, message: nil, context: nil, root: true)
  @hash     = resource
  @resource = resource
  @meta     = meta
  @message  = message
  @context  = context || {}
  @root     = root
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



12
13
14
# File 'lib/pi_resources/serializer/hash_serializer.rb', line 12

def hash
  @hash
end

#messageObject (readonly)

Returns the value of attribute message.



12
13
14
# File 'lib/pi_resources/serializer/hash_serializer.rb', line 12

def message
  @message
end

#metaObject (readonly)

Returns the value of attribute meta.



12
13
14
# File 'lib/pi_resources/serializer/hash_serializer.rb', line 12

def meta
  @meta
end

#rootObject (readonly)

Returns the value of attribute root.



12
13
14
# File 'lib/pi_resources/serializer/hash_serializer.rb', line 12

def root
  @root
end

Instance Method Details

#dataObject



23
24
25
# File 'lib/pi_resources/serializer/hash_serializer.rb', line 23

def data
  hash
end