Class: Rspec::Bash::BashStubMarshaller

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/bash/server/bash_stub_marshaller.rb

Instance Method Summary collapse

Instance Method Details

#marshal(object_to_marshal) ⇒ Object



13
14
15
16
# File 'lib/rspec/bash/server/bash_stub_marshaller.rb', line 13

def marshal(object_to_marshal)
  object_to_dump = Sparsify.sparse(object_to_marshal, sparse_array: true)
  JSON.pretty_generate(object_to_dump, indent: '', space: '')
end

#unmarshal(message_to_unmarshal) ⇒ Object



7
8
9
10
11
# File 'lib/rspec/bash/server/bash_stub_marshaller.rb', line 7

def unmarshal(message_to_unmarshal)
  object_to_unflatten = JSON.parse(message_to_unmarshal)
  unflattened_object = Sparsify.unsparse(object_to_unflatten)
  JSON.parse(JSON.dump(unflattened_object), symbolize_names: true)
end