Class: Object

Inherits:
BasicObject
Defined in:
lib/ronin/extensions/meta/object.rb

Overview

metaprogramming assistant -- metaid.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) class_def(name, &blk)

Defines an instance method within a class



21
22
23
# File 'lib/ronin/extensions/meta/object.rb', line 21

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

- (Object) meta_def(name, &blk)

Adds methods to a metaclass



16
17
18
# File 'lib/ronin/extensions/meta/object.rb', line 16

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

- (Object) meta_eval(&blk)



5
# File 'lib/ronin/extensions/meta/object.rb', line 5

def meta_eval(&blk); metaclass.instance_eval(&blk); end

- (Object) metaclass

The hidden singleton lurks behind everyone



4
# File 'lib/ronin/extensions/meta/object.rb', line 4

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

- (Object) metaclass_def(name, &blk)

A class_def version of meta_def



11
12
13
# File 'lib/ronin/extensions/meta/object.rb', line 11

def metaclass_def(name, &blk)
  metaclass_eval { define_method(name, &blk) }
end

- (Object) metaclass_eval(&blk)

A class_eval version of meta_eval



8
# File 'lib/ronin/extensions/meta/object.rb', line 8

def metaclass_eval(&blk); metaclass.class_eval(&blk); end