Skip to content

Instantly share code, notes, and snippets.

@dsabira
dsabira / dog.rb
Created November 9, 2019 18:05 — forked from shiroyasha/dog.rb
Method tracer for Ruby classes
class Dog
attr_writer :name
def initialize(name)
@name = name
end
def bark
puts "patrick"
end
@dsabira
dsabira / eigenclass.rb
Created November 9, 2019 18:04 — forked from SaitoWu/eigenclass.rb
some ruby meta programming demo.
#Person
class Person
end
#class method
class Person
def self.address
puts "hangzhou"
end
end
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros