Sha256: d9932afd762870d81fd1876d5dee115b207cc3b10ef4923f2f527d4c03362355
Contents?: true
Size: 867 Bytes
Versions: 12
Compression:
Stored size: 867 Bytes
Contents
class Card module Env # serializing environment (eg for delayed jobs) module Serialization def serialize @serialized = Serializable.instance_methods.each_with_object({}) do |attr, hash| hash[attr] = send attr end end # @param serialized_env [Hash] def with serialized_env tmp_env = serialize @serialized.update serialized_env yield ensure @serialized.update tmp_env if tmp_env end # supercede serializable methods when serialized values are available # # note - at present this must be done manually when adding serializable methods # in mods. Serializable.instance_methods.each do |attrib| define_method attrib do @serialized&.key?(attrib) ? @serialized[attrib] : super() end end end end end
Version data entries
12 entries across 12 versions & 1 rubygems