Sha256: a8a9999ce0191558e4a5556d2c14b917b3deda38ec2ae86f34f9ba8db09c6ee4
Contents?: true
Size: 926 Bytes
Versions: 31
Compression:
Stored size: 926 Bytes
Contents
# frozen_string_literal: true 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 StandardError thing end else thing end end end end end
Version data entries
31 entries across 31 versions & 1 rubygems