Paolo Perrotta - Metaprogramming Ruby

Chapter 3 - Blocks
- New scopes are started inside
- A class defined with
classkeyword - A module defined with the
modulekeyword - A method defined witht the
defkeyword
- A class defined with
- To use something from an existing scope you must use the dynamic definition methods
Class.new,Module.new,define_method - Use
BasicObjectderived classes as clean room for DSL execution to have less methods available
Chapter 4 - Class definitions
classkeyword =class_eval=instance_evalon the Class object- Inside a class definition you can:
selfis the class inside
flowchart LR
obj -- class --> MyClass
MyClass -- superclass --> Object
MyClass -- class --> #MyClass
Object -- class --> #Object
#MyClass -- superclass --> #Object
Object -- superclass --> BasicObject
BasicObject -- class --> #BasicObject
#Object -- superclass --> #BasicObject
#BasicObject -- superclass --> Class
- Super class of a singleton class is singleton class of superclass