Class: Code::Object::IdentifierList

Inherits:
List show all
Defined in:
lib/code/object/identifier_list.rb

Constant Summary

Constants inherited from Code::Object

NUMBER_CLASSES

Instance Attribute Summary

Attributes inherited from Code::Object

#raw

Instance Method Summary collapse

Methods inherited from List

#any?, #code_any?, #code_append, #code_compact, #code_compact!, #code_detect, #code_each, #code_first, #code_flatten, #code_get, #code_include?, #code_join, #code_last, #code_map, #code_map!, #code_max, #code_max_by, #code_none?, #code_reduce, #code_reject, #code_reject!, #code_reverse, #code_sample, #code_select, #code_select!, #code_size, #code_sort, #code_sum, #code_uniq, #initialize

Methods inherited from Code::Object

#<=>, #==, as_json, #as_json, call, #code_and_operator, code_and_operator, code_as_json, #code_as_json, #code_different, code_different, #code_equal_equal, code_equal_equal, code_equal_equal_equal, #code_equal_equal_equal, code_exclamation_point, #code_exclamation_point, code_exclusive_range, #code_exclusive_range, code_inclusive_range, #code_inclusive_range, code_new, code_or_operator, #code_or_operator, #code_self, code_self, #code_to_json, code_to_json, falsy?, #falsy?, #hash, #initialize, inspect, maybe, #multi_fetch, multi_fetch, nothing?, #nothing?, repeat, sig, #sig, #succ, #to_code, to_json, #to_json, to_s, truthy?, #truthy?, |

Constructor Details

This class inherits a constructor from Code::Object::List

Instance Method Details

#call(**args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/code/object/identifier_list.rb', line 6

def call(**args)
  code_operator = args.fetch(:operator, nil).to_code
  code_arguments = args.fetch(:arguments, []).to_code
  code_context = args.fetch(:context).to_code
  code_value = code_arguments.code_first

  case code_operator.to_s
  when /=$/
    sig(args) { Object }

    code_context = code_context.code_lookup!(raw.first)

    code_context =
      raw[..-2].reduce(code_context) do |code_context, code_identifier|
        code_context.code_fetch(code_identifier)
      end

    code_context.code_set(
      raw.last,
      if code_operator.to_s == "="
        code_value
      else
        code_context.fetch(raw.last).call(
          **args,
          operator: code_operator.to_s.chop,
          arguments: [code_value]
        )
      end
    )

    code_context.code_fetch(raw.last)
  else
    super
  end
end