Class: Object

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

Instance Method Summary collapse

Instance Method Details

#meta_def(sym, &block) ⇒ Object



14
15
16
17
18
# File 'lib/core_ext/object.rb', line 14

def meta_def(sym, &block)
  meta_eval do
    define_method(sym, &block)
  end
end

#meta_eval(&block) ⇒ Object



10
11
12
# File 'lib/core_ext/object.rb', line 10

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

#metaclassObject



6
7
8
# File 'lib/core_ext/object.rb', line 6

def metaclass
  class << self; self end
end

#try(sym, *args, &block) ⇒ Object



2
3
4
# File 'lib/core_ext/object.rb', line 2

def try(sym, *args, &block)
  respond_to?(sym) ? send(sym, *args, &block) : nil
end