Sha256: 3df8d33fb7feabe48895246c9b42db73852cf1f3d9adb5b942c6830a148cd230
Contents?: true
Size: 708 Bytes
Versions: 3
Compression:
Stored size: 708 Bytes
Contents
module AppManifest # Serialization logic for AppManifest models module Serializer def self.serialize(value) case value when Array value.map { |v| serialize(v) } when Hash value.each_with_object({}) do |(k, v), h| h[k] = serialize(v) end when Integer, Float, String, Symbol, TrueClass, FalseClass, NilClass value else if value.respond_to?(:attributes) value.attributes.each_with_object({}) do |(key, val), hash| hash[key] = serialize(val) unless val.nil? end else val.to_s end end end def to_hash Serializer.serialize(self) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
app_manifest-0.5.0 | lib/app_manifest/serializer.rb |
app_manifest-0.4.0 | lib/app_manifest/serializer.rb |
app_manifest-0.3.0 | lib/app_manifest/serializer.rb |