Class: PanStuff::Serializer::HashSerializer

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/pan_stuff/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.



10
11
12
13
14
15
16
17
# File 'lib/pan_stuff/serializer/hash_serializer.rb', line 10

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.



8
9
10
# File 'lib/pan_stuff/serializer/hash_serializer.rb', line 8

def hash
  @hash
end

#messageObject (readonly)

Returns the value of attribute message.



8
9
10
# File 'lib/pan_stuff/serializer/hash_serializer.rb', line 8

def message
  @message
end

#metaObject (readonly)

Returns the value of attribute meta.



8
9
10
# File 'lib/pan_stuff/serializer/hash_serializer.rb', line 8

def meta
  @meta
end

#rootObject (readonly)

Returns the value of attribute root.



8
9
10
# File 'lib/pan_stuff/serializer/hash_serializer.rb', line 8

def root
  @root
end

Instance Method Details

#dataObject



19
20
21
# File 'lib/pan_stuff/serializer/hash_serializer.rb', line 19

def data
  hash
end