Class: Object

Inherits:
BasicObject
Defined in:
lib/scoring_rules/metaid.rb

Overview

Code by why_the_lucky_stiff

Instance Method Summary collapse

Instance Method Details

#class_def(name, &blk) ⇒ Object

Defines an instance method within a class



14
15
16
# File 'lib/scoring_rules/metaid.rb', line 14

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

#meta_def(name, &blk) ⇒ Object

Adds methods to a metaclass



9
10
11
# File 'lib/scoring_rules/metaid.rb', line 9

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

#meta_eval(&blk) ⇒ Object



6
# File 'lib/scoring_rules/metaid.rb', line 6

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

#metaclassObject

The hidden singleton lurks behind everyone



5
# File 'lib/scoring_rules/metaid.rb', line 5

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