Class: Object

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

Overview

Basic, add an alias_method to the object class

Add returning to the object

Instance Method Summary collapse

Instance Method Details

#alias_method(new_id, original_id) ⇒ Object



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

def alias_method(new_id, original_id)
  original = self.method(original_id).to_proc
  define_method(new_id){|*args| original.call(*args)}
end

#extended(&block) ⇒ Object



17
18
19
20
# File 'lib/core/object.rb', line 17

def extended(&block)
  block.in_context(self).call
  self
end

#my_methodsObject



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

def my_methods
  self.methods.sort - (self.class.methods + self.class.superclass.methods)
end

#returning(receiver) {|receiver| ... } ⇒ Object

Yields:

  • (receiver)


13
14
15
16
# File 'lib/core/object.rb', line 13

def returning(receiver)
  yield receiver
  receiver
end