Class: Code::Object::Super

Inherits:
Function show all
Defined in:
lib/code/object/super.rb

Constant Summary

Constants inherited from Code::Object

NUMBER_CLASSES

Instance Attribute Summary

Attributes inherited from Function

#code_body, #code_parameters, #definition_context, #parent

Attributes included from Concerns::Shared

#methods, #raw

Instance Method Summary collapse

Methods inherited from Function

#code_call, #code_extend, #code_fetch, #code_get, #code_has_key?, #code_set, #code_to_string, #signature_for_call

Methods inherited from Code::Object

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

Methods included from Concerns::Shared

#<=>, #==, #as_json, #blank?, #code_and, #code_as_json, #code_blank?, #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_presence, #code_presence_in, #code_present?, #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?, #present?, #sig, #something?, #succ, #to_code, #to_i, #to_json, #to_s, #truthy?

Constructor Details

#initialize(parent, forwarded_arguments, code_self, definition_context, explicit_arguments: false) ⇒ Super

Returns a new instance of Super.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/code/object/super.rb', line 6

def initialize(
  parent,
  forwarded_arguments,
  code_self,
  definition_context,
  explicit_arguments: false
)
  @parent = parent.to_code
  @forwarded_arguments = forwarded_arguments.to_code
  @code_self = code_self.to_code
  @definition_context = definition_context
  self.methods = Dictionary.new
  self.raw = @parent.raw
end

Instance Method Details

#call(**args) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/code/object/super.rb', line 21

def call(**args)
  code_arguments = args.fetch(:arguments, List.new).to_code
  explicit_arguments = args.fetch(:explicit_arguments, false)

  @parent.code_call(
    *(arguments_for(code_arguments, explicit_arguments).raw),
    explicit_arguments: explicit_arguments,
    bound_self: @code_self,
    **multi_fetch(args, *GLOBALS).merge(context: parent_context)
  )
end