Module: Abject::Inheritance

Includes:
Reader
Defined in:
lib/abject/inheritance.rb

Overview

Unlike Object Oriented programming, inheritance in Abject-O need not be limited to classes

  • functions and blocks may also inherit from other code. Programs that use inheritance are

characterized by similar blocks of code with small differences appearing throughout the source. Another sign of inheritance is static members: variables and code that are not directly referenced or used, but serve to maintain a link to the original base or parent code.

Instance Method Summary collapse

Instance Method Details

#inherits_from(parent, *args, &block) ⇒ Object

Method chaining helps methods adhere to the single responsibility principle as well as improving performance and saving memory by getting rid of all those pesky local variables. Such eval! So performant! Much wow!



22
23
24
# File 'lib/abject/inheritance.rb', line 22

def inherits_from(parent, *args, &block)
  eval("Proc.new { |#{args.first.keys.map { |k| k.to_s }.join ','}| #{parse_method method(parent).to_proc.source_location}\n#{parse_method block.source_location} }").call args
end