Sha256: 39606b86cf59509a95940ac02010b1d9c146a4d7100db3f7e0797bdaa819ee4c
Contents?: true
Size: 635 Bytes
Versions: 7
Compression:
Stored size: 635 Bytes
Contents
class BMC::MiniModelSerializer::Serialize attr_reader :object, :options def self.call(...) new(...).call end def initialize(object, options = {}) @object = object @options = options end def call if object.is_a?(Hash) object.to_h { |k, v| [k.to_s, serialize(v)] } elsif object.is_a?(Enumerable) object.map { |e| serialize(e) } elsif (serializer = "#{object.class}Serializer".safe_constantize) serializer.call(object, options) else object.as_json end end private def serialize(object) BMC::MiniModelSerializer::Serialize.call(object, options) end end
Version data entries
7 entries across 7 versions & 1 rubygems