Module: Card::Env::Serialization

Included in:
Card::Env
Defined in:
card/lib/card/env/serialization.rb

Overview

serializing environment (eg for delayed jobs)

Instance Method Summary collapse

Instance Method Details

#serializeObject



5
6
7
8
9
# File 'card/lib/card/env/serialization.rb', line 5

def serialize
  @serialized = Serializable.instance_methods.each_with_object({}) do |attr, hash|
    hash[attr] = send attr
  end
end

#with(serialized_env) ⇒ Object

Parameters:

  • serialized_env (Hash)


12
13
14
15
16
17
18
# File 'card/lib/card/env/serialization.rb', line 12

def with serialized_env
  tmp_env = serialize
  @serialized.update serialized_env
  yield
ensure
  @serialized.update tmp_env if tmp_env
end