Sha256: d5b35de419cecba7885374a52b864f525ffea938d7e4cf69feb985fc960615d0
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require_relative '../exceptions' require 'dentaku/string_casing' module Dentaku module AST class Identifier < Node include StringCasing attr_reader :identifier, :case_sensitive def initialize(token, options = {}) @case_sensitive = options.fetch(:case_sensitive, false) @identifier = standardize_case(token.value) end def value(context = {}) v = context.fetch(identifier) do raise UnboundVariableError.new([identifier]), "no value provided for variables: #{identifier}" end case v when Node value = v.value(context) context[identifier] = value if Dentaku.cache_identifier? value when Proc v.call else v end end def dependencies(context = {}) context.key?(identifier) ? dependencies_of(context[identifier], context) : [identifier] end private def dependencies_of(node, context) node.respond_to?(:dependencies) ? node.dependencies(context) : [] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dentaku-3.4.2 | lib/dentaku/ast/identifier.rb |