Class: Code::Object::Super
- Inherits:
-
Function
- Object
- Code::Object
- Function
- Code::Object::Super
- Defined in:
- lib/code/object/super.rb
Constant Summary collapse
- CLASS_DOCUMENTATION =
{ name: "Super", description: "calls the captured parent function available inside an extended function.", examples: [ "Base = () => { self.name = :base self } Child = Base.extend(() => { super() }) Child().name", "Base = (name) => { self.name = name self } Child = Base.extend((...) => { super(...) }) Child(:ada).name", "Base = () => { 1 } Child = Base.extend(() => { super() + 1 }) Child()" ] }.freeze
Constants inherited from Function
Constants inherited from Code::Object
CLASS_FUNCTIONS, INSTANCE_FUNCTIONS, NUMBER_CLASSES
Constants included from Concerns::Shared
Concerns::Shared::COMPOUND_ASSIGNMENT_OPERATORS, Concerns::Shared::OPERATOR_METHOD_ALIASES, Concerns::Shared::SHARED_OPERATORS
Instance Attribute Summary
Attributes inherited from Function
#code_body, #code_parameters, #definition_context, #documentation, #instance_functions, #parent
Attributes included from Concerns::Shared
Instance Method Summary collapse
- #call(**args) ⇒ Object
-
#initialize(parent, forwarded_arguments, code_self, definition_context, explicit_arguments: false) ⇒ Super
constructor
A new instance of Super.
Methods inherited from Function
#code_call, #code_class_functions, #code_deep_duplicate, #code_extend, #code_fetch, #code_functions, #code_get, #code_has_key?, #code_instance_functions, #code_replace, #code_set, #code_to_string, function_documentation, #signature_for_call
Methods inherited from Code::Object
class_documentation, class_functions, code_new, #code_new, documentation, documentation_for, documented_functions_for, function_documentation, function_documentation_for, function_documentation_registry_for, functions, inherited_function_documentation_for, instance_functions, maybe, #name, repeat, sorted_dictionary, |
Methods included from Concerns::Shared
#<=>, #==, #as_json, #blank?, #code_and, #code_as_json, #code_blank?, #code_class_functions, #code_compare, #code_deep_duplicate, #code_different, #code_documentable_functions, #code_documentation, #code_duplicate, #code_dynamic_call, #code_equal, #code_exclamation_mark, #code_exclusive_range, #code_false?, #code_falsy?, code_fetch, #code_fetch, #code_functions, code_get, #code_get, #code_greater, #code_greater_or_equal, #code_has_key?, #code_inclusive_range, #code_inspect, #code_instance_functions, #code_instance_of?, #code_is_a?, #code_itself, #code_less, #code_less_or_equal, #code_name, #code_nothing?, #code_or, #code_presence, #code_presence_in, #code_present?, #code_respond_to?, #code_same_object?, #code_self, #code_send, code_set, #code_set, #code_something?, #code_strict_different, #code_strict_equal, #code_tap, #code_then, #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_true?, #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.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/code/object/super.rb', line 16 def initialize( parent, forwarded_arguments, code_self, definition_context, explicit_arguments: false ) _explicit_arguments = explicit_arguments @parent = parent.to_code @forwarded_arguments = forwarded_arguments.to_code @code_self = code_self.to_code @definition_context = definition_context self.functions = Dictionary.new self.raw = @parent.raw end |
Instance Method Details
#call(**args) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/code/object/super.rb', line 32 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 |