Class: SoberSwag::Serializer::Meta
- Inherits:
-
Base
- Object
- Base
- SoberSwag::Serializer::Meta
show all
- Defined in:
- lib/sober_swag/serializer/meta.rb
Overview
Provides metadata on a serializer.
All actions delegate to the base.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
#array, #identifier, #optional, #serializer, #via_map
Constructor Details
#initialize(base, meta) ⇒ Meta
Returns a new instance of Meta.
7
8
9
10
11
|
# File 'lib/sober_swag/serializer/meta.rb', line 7
def initialize(base, meta)
@base = base
@metadata = meta
@identifier = @base.identifier
end
|
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
13
14
15
|
# File 'lib/sober_swag/serializer/meta.rb', line 13
def base
@base
end
|
Returns the value of attribute metadata.
13
14
15
|
# File 'lib/sober_swag/serializer/meta.rb', line 13
def metadata
@metadata
end
|
Instance Method Details
#finalize_lazy_type! ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/sober_swag/serializer/meta.rb', line 31
def finalize_lazy_type!
@base.finalize_lazy_type!
%i[lazy_type type].each do |sym|
if @base.public_send(sym).respond_to?(:identifier) && public_send(sym).respond_to?(:identifier)
public_send(sym).identifier(@base.public_send(sym).identifier)
end
end
end
|
#lazy_type ⇒ Object
23
24
25
|
# File 'lib/sober_swag/serializer/meta.rb', line 23
def lazy_type
@lazy_type ||= @base.lazy_type.meta(**metadata)
end
|
#lazy_type? ⇒ Boolean
43
44
45
|
# File 'lib/sober_swag/serializer/meta.rb', line 43
def lazy_type?
@base.lazy_type?
end
|
19
20
21
|
# File 'lib/sober_swag/serializer/meta.rb', line 19
def meta(hash)
self.class.new(base, metadata.merge(hash))
end
|
#serialize(args, opts = {}) ⇒ Object
15
16
17
|
# File 'lib/sober_swag/serializer/meta.rb', line 15
def serialize(args, opts = {})
base.serialize(args, opts)
end
|
#type ⇒ Object
27
28
29
|
# File 'lib/sober_swag/serializer/meta.rb', line 27
def type
@type ||= @base.type.meta(**metadata)
end
|