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 included from Concerns::Shared

#methods, #raw

Instance Method Summary collapse

Methods inherited from List

#any?, #code_all?, #code_any?, #code_append, #code_compact, #code_compact!, #code_deep_duplicate, #code_detect, #code_each, #code_fetch, #code_first, #code_flatten, #code_get, #code_include?, #code_join, #code_last, #code_map, #code_map!, #code_max, #code_minus, #code_none?, #code_pop, #code_pop!, #code_reduce, #code_reject, #code_reject!, #code_reverse, #code_sample, #code_select, #code_select!, #code_set, #code_shift, #code_shuffle, #code_size, #code_sort, #code_sum, #code_uniq, #initialize

Methods inherited from Code::Object

code_new, #code_new, #initialize, maybe, #name, repeat, |

Methods included from Concerns::Shared

#<=>, #==, #as_json, #code_and, #code_as_json, #code_compare, #code_deep_duplicate, #code_different, #code_duplicate, #code_equal, #code_exclamation_mark, #code_exclusive_range, #code_falsy?, code_fetch, #code_fetch, code_get, #code_get, #code_greater, #code_greater_or_equal, #code_inclusive_range, #code_inspect, #code_less, #code_less_or_equal, #code_methods, #code_name, #code_nothing?, #code_or, #code_self, #code_set, code_set, #code_something?, #code_strict_different, #code_strict_equal, #code_to_boolean, #code_to_class, #code_to_date, #code_to_decimal, #code_to_dictionary, #code_to_duration, #code_to_integer, #code_to_json, #code_to_list, #code_to_nothing, #code_to_parameter, #code_to_range, #code_to_string, #code_to_time, #code_truthy?, #eql?, #falsy?, #hash, #inspect, #multi_fetch, #nothing?, #sig, #something?, #succ, #to_code, #to_i, #to_json, #to_s, #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.code_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