Sha256: 5c3bb68c79ac91648638225c7db324cb9c7fadb489d14083bccf28b26187950c
Contents?: true
Size: 784 Bytes
Versions: 13
Compression:
Stored size: 784 Bytes
Contents
module Spira module Serialization ## # Support for Psych (YAML) custom serializer. # # This causes the subject and all attributes to be saved to a YAML or JSON serialization # in such a way that they can be restored in the future. # # @param [Psych::Coder] coder def encode_with(coder) coder["subject"] = subject attributes.each {|p,v| coder[p.to_s] = v if v} end ## # Support for Psych (YAML) custom de-serializer. # # Updates a previously allocated Spira::Base instance to that of a previously # serialized instance. # # @param [Psych::Coder] coder def init_with(coder) instance_variable_set(:"@subject", coder["subject"]) assign_attributes coder.map.except("subject") end end end
Version data entries
13 entries across 13 versions & 1 rubygems