Module: KeywordHashBuilder::BacktickPatch

Defined in:
lib/keyword_hash_builder.rb

Instance Method Summary collapse

Instance Method Details

#`(str) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/keyword_hash_builder.rb', line 6

def `(str)
  RubyVM::DebugInspector.open do |inspector|
    str.split(?,).zip(eval("[#{str}]", inspector.frame_binding(2))).to_h.reduce({}) do |mem, (k,v)|
      mem.tap { mem[k.to_sym] = v }
    end
  end
end