Module: Kernel

Defined in:
lib/relevance/core_extensions/metaclass.rb,
lib/relevance/core_extensions/metaclass.rb

Overview

From /lib/more/facets/kernel/meta.rb

Instance Method Summary collapse

Instance Method Details

#eigenclassObject



36
37
38
# File 'lib/relevance/core_extensions/metaclass.rb', line 36

def eigenclass
  (class << self; self; end)
end

#metaObject



56
57
58
59
60
# File 'lib/relevance/core_extensions/metaclass.rb', line 56

def meta
  @_meta_functor ||= Functor.new do |op,*args|
    (class << self; self; end).send(op,*args)
  end
end

#meta_alias(*args) ⇒ Object



6
7
8
9
10
# File 'lib/relevance/core_extensions/metaclass.rb', line 6

def meta_alias(*args)
  meta_class do
    alias_method(*args)
  end
end

#meta_class(&block) ⇒ Object Also known as: metaclass



26
27
28
29
30
31
32
# File 'lib/relevance/core_extensions/metaclass.rb', line 26

def meta_class(&block)
  if block_given?
    (class << self; self; end).class_eval(&block)
  else
    (class << self; self; end)
  end
end

#meta_def(name, &block) ⇒ Object



20
21
22
23
24
# File 'lib/relevance/core_extensions/metaclass.rb', line 20

def meta_def( name, &block )
  meta_class do
    define_method( name, &block )
  end
end

#meta_eval(str = nil, &blk) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/relevance/core_extensions/metaclass.rb', line 12

def meta_eval(str=nil, &blk)
  if str
    meta_class.instance_eval(str)
  else
    meta_class.instance_eval(&blk)
  end
end