Sha256: 53c6bfba040a8d81adc0d9d5109f49cf63251986ec824b9e9d5a803154ea72f5
Contents?: true
Size: 791 Bytes
Versions: 1
Compression:
Stored size: 791 Bytes
Contents
module Egi class Sandbox def initialize @current_env = :default end def envs @envs ||= Hash.new {|hash, key| hash[key] = Env.new(key) } end def env(name, opts = {}, &block) name = name.to_sym @current_env = name to_load = opts[:load] env = envs[name] env.merge!(envs[to_load]) if envs.has_key?(to_load) env.instance_eval(&block) if block_given? # define method_missing to access item def env.method_missing(name, *args) raise MethodMissing if args.size > 0 items.has_key?(name) ? items[name] : nil end end def eval(str) instance_eval(str) envs end def method_missing(name, *args) envs[@current_env].send(name, *args) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
egi-0.0.2 | lib/egi/sandbox.rb |