Sha256: 0ccf1e49e7cb4b4cb462db7f94051d4ab9b7d420c181ddd0f1c563f09070efad
Contents?: true
Size: 690 Bytes
Versions: 25
Compression:
Stored size: 690 Bytes
Contents
# frozen_string_literal: true class Code class Object class Context < Dictionary attr_reader :parent def initialize(raw = {}, parent: nil) @raw = raw @parent = parent end def self.name "Context" end def lookup!(identifier) if code_has_key?(identifier).truthy? self elsif parent? parent.lookup!(identifier) else raise Code::Error::Undefined, "#{identifier} is not defined" end end def merge(other) Context.new(raw.merge(other.raw), parent: parent || other.parent) end def parent? !!parent end end end end
Version data entries
25 entries across 25 versions & 1 rubygems