Module: Card::Env::Serialization

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

Overview

serializing environment (eg for delayed jobs)

Constant Summary collapse

SERIALIZABLE_ATTRIBUTES =
::Set.new %i[
  main_name params ip ajax html host protocol salt
]

Instance Method Summary collapse

Instance Method Details

#serializeObject



19
20
21
# File 'card/lib/card/env/serialization.rb', line 19

def serialize
  @env.select { |k, _v| SERIALIZABLE_ATTRIBUTES.include?(k) }
end

#with(serialized_env) ⇒ Object

Parameters:

  • serialized_env (Hash)


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

def with serialized_env
  tmp_env = serialize if @env
  @env ||= {}
  @env.update serialized_env
  yield
ensure
  @env.update tmp_env if tmp_env
end