Class: Object

Inherits:
BasicObject
Defined in:
lib/sequel/metaprogramming.rb

Overview

why the lucky stiff’s helper for making metaclasses

Instance Method Summary collapse

Instance Method Details

#class_def(name, &blk) ⇒ Object

Defines an instance method within a class



26
27
28
# File 'lib/sequel/metaprogramming.rb', line 26

def class_def name, &blk
  class_eval { define_method name, &blk }
end

#inst_def(name, &blk) ⇒ Object

Defines an class method within a class



31
32
33
# File 'lib/sequel/metaprogramming.rb', line 31

def inst_def name, &blk
  define_method name, &blk
end

#meta_def(name, &blk) ⇒ Object

Adds methods to a metaclass



17
18
19
# File 'lib/sequel/metaprogramming.rb', line 17

def meta_def name, &blk
  meta_eval { define_method name, &blk }
end

#meta_eval(&blk) ⇒ Object



14
# File 'lib/sequel/metaprogramming.rb', line 14

def meta_eval &blk; metaclass.class_eval &blk; end

#metaclassObject

The hidden singleton lurks behind everyone



13
# File 'lib/sequel/metaprogramming.rb', line 13

def metaclass; class << self; self; end; end