Sha256: 4777d3d052da3c6c4ab9a0abef9c5043e6958b629985dae613b239ec7b33bb5f
Contents?: true
Size: 648 Bytes
Versions: 2
Compression:
Stored size: 648 Bytes
Contents
module Confidante module Converters class EvaluatingConverter def convert(thing) case thing when Hash convert_hash(thing) when Array convert_array(thing) else convert_item(thing) end end private def convert_hash(thing) {}.tap do |h| thing.each { |k, v| h[k.to_sym] = convert(v) } end end def convert_array(thing) thing.map { |v| convert(v) } end def convert_item(thing) begin eval(thing, binding) rescue thing end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
confidante-0.9.0 | lib/confidante/converters/evaluating_converter.rb |
confidante-0.8.0.pre.1 | lib/confidante/converters/evaluating_converter.rb |