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
- #eigenclass ⇒ Object
- #meta ⇒ Object
- #meta_alias(*args) ⇒ Object
- #meta_class(&block) ⇒ Object (also: #metaclass)
- #meta_def(name, &block) ⇒ Object
- #meta_eval(str = nil, &blk) ⇒ Object
Instance Method Details
#eigenclass ⇒ Object
36 37 38 |
# File 'lib/relevance/core_extensions/metaclass.rb', line 36 def eigenclass (class << self; self; end) end |
#meta ⇒ Object
56 57 58 59 60 |
# File 'lib/relevance/core_extensions/metaclass.rb', line 56 def @_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 (*args) 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 (&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 ( name, &block ) 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 (str=nil, &blk) if str .instance_eval(str) else .instance_eval(&blk) end end |