Class: Object

Inherits:
BasicObject
Defined in:
lib/ambition/core_ext.rb

Overview

Object extensions to make metaprogramming a little easier.

Instance Method Summary collapse

Instance Method Details

#class_def(name, &blk) ⇒ Object



6
# File 'lib/ambition/core_ext.rb', line 6

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

#meta_def(name, &blk) ⇒ Object



5
# File 'lib/ambition/core_ext.rb', line 5

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

#meta_eval(&blk) ⇒ Object



4
# File 'lib/ambition/core_ext.rb', line 4

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

#metaclassObject



3
# File 'lib/ambition/core_ext.rb', line 3

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

#recursive_const_get(name) ⇒ Object



7
8
9
# File 'lib/ambition/core_ext.rb', line 7

def recursive_const_get(name)
  name.split('::').inject(Object) {|klass,name| klass.const_get(name) }
end