class SoberSwag::Serializer::Meta
Provides metadata on a serializer. All actions delegate to the base.
Attributes
base[R]
metadata[R]
Public Class Methods
new(base, meta)
click to toggle source
# File lib/sober_swag/serializer/meta.rb, line 7 def initialize(base, meta) @base = base @metadata = meta @identifier = @base.identifier end
Public Instance Methods
finalize_lazy_type!()
click to toggle source
# File lib/sober_swag/serializer/meta.rb, line 31 def finalize_lazy_type! @base.finalize_lazy_type! # Using .meta on dry-struct returns a *new type* that wraps the old one. # As such, we need to be a bit clever about when we tack on the identifier # for this 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()
click to toggle source
# File lib/sober_swag/serializer/meta.rb, line 23 def lazy_type @lazy_type ||= @base.lazy_type.meta(**metadata) end
lazy_type?()
click to toggle source
# File lib/sober_swag/serializer/meta.rb, line 43 def lazy_type? @base.lazy_type? end
meta(hash)
click to toggle source
# File lib/sober_swag/serializer/meta.rb, line 19 def meta(hash) self.class.new(base, metadata.merge(hash)) end
serialize(args, opts = {})
click to toggle source
# File lib/sober_swag/serializer/meta.rb, line 15 def serialize(args, opts = {}) base.serialize(args, opts) end
type()
click to toggle source
# File lib/sober_swag/serializer/meta.rb, line 27 def type @type ||= @base.type.meta(**metadata) end