Sha256: b07b55987db20e5c57d2c80058fa712effe7f26abb330f1bd328d6c5a39690be
Contents?: true
Size: 891 Bytes
Versions: 15
Compression:
Stored size: 891 Bytes
Contents
require 'shikashi' module Confidante module Converters class EvaluatingConverter def initialize @sandbox = Shikashi::Sandbox.new @privileges = Shikashi::Privileges.new end 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) if thing =~ /^[\[,{]/ begin @sandbox.run(@privileges, thing) rescue Exception thing end else thing end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems