Module: PanStuff::Serializer::ObjectSerializer
Constant Summary
Constants included
from Base
Base::TRANSFORMS_MAPPING
Instance Method Summary
collapse
Methods included from Base
#as_json, #run_key_transform!, #to_h
Instance Method Details
#data ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/pan_stuff/serializer/object_serializer.rb', line 38
def data
if self.class.collection? @resource
data_for_collection
else
data_for_one_record
end
end
|
#initialize(resource, meta: nil, message: nil, context: nil, root: true) ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/pan_stuff/serializer/object_serializer.rb', line 21
def initialize(resource, meta: nil, message: nil, context: nil, root: true)
@resource = resource
@meta = meta
@message = message
@context = context || {}
@root = root
end
|
46
47
48
49
50
|
# File 'lib/pan_stuff/serializer/object_serializer.rb', line 46
def meta
@meta&.deep_transform_keys do |k|
run_key_transform!(k)
end
end
|
#serializable_hash! ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/pan_stuff/serializer/object_serializer.rb', line 52
def serializable_hash!
if root
use_root
else
data
end
end
|