Sha256: e92886196c7b403e535048c0bc926a9b1e80578984191616c6664e575cb180d6
Contents?: true
Size: 754 Bytes
Versions: 26
Compression:
Stored size: 754 Bytes
Contents
# frozen_string_literal: true class Code class Object class Context < Dictionary attr_reader :parent def initialize(*args, **_kargs, &_block) raw = args.first || Dictionary.new raw = raw.raw if raw.is_a?(Object) @raw = raw.to_h @parent = Context.new(args.second) if args.second end def lookup!(identifier) if code_has_key?(identifier).truthy? self elsif parent? parent.lookup!(identifier) else raise Error::Undefined, "#{identifier} is not defined" end end def merge(other) Context.new(raw.merge(other.raw), parent || other.parent) end def parent? !!parent end end end end
Version data entries
26 entries across 26 versions & 1 rubygems