Sha256: 6bc8da0d0b072c85d260735526eff63625b9df0ce7500f164f528bcf16e0b320
Contents?: true
Size: 748 Bytes
Versions: 3
Compression:
Stored size: 748 Bytes
Contents
# frozen_string_literal: true class Code class Object class Context < Dictionary attr_reader :parent def initialize(*args, **_kargs, &) 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
code-ruby-1.1.3 | lib/code/object/context.rb |
code-ruby-1.1.1 | lib/code/object/context.rb |
code-ruby-1.1.0 | lib/code/object/context.rb |