Module: CrossStub::Arguments::Hash

Defined in:
lib/cross-stub/arguments/hash.rb

Class Method Summary collapse

Class Method Details

.parse(hash) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/cross-stub/arguments/hash.rb', line 6

def parse(hash)
  hash.inject({}) do |memo, (name, val)|
    marshalized = Base64.encode64(Marshal.dump(val)).gsub('|','\|')
    code = "def #{name} ; Marshal.load(Base64.decode64(%|#{marshalized}|)) ; end"
    memo.merge(:"#{name}" => code)
  end
end