Module: Object::ObjectExtensions

Included in:
Object
Defined in:
lib/libmatty/object.rb

Instance Method Summary collapse

Instance Method Details

#meta_def(name, &blk) ⇒ Object



11
# File 'lib/libmatty/object.rb', line 11

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

#meta_eval(&blk) ⇒ Object



10
# File 'lib/libmatty/object.rb', line 10

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

#metaclassObject

Every object has a “singleton” class, which you can think of as the class (ie, 1.metaclass =~ Fixnum) — but that you can modify and extend without fucking up the actual class.



9
# File 'lib/libmatty/object.rb', line 9

def metaclass; class << self; self; end; end

#mymethodsObject

This is from Topher Cyll’s Stupd IRB tricks



28
29
30
# File 'lib/libmatty/object.rb', line 28

def mymethods
  (self.methods - self.class.superclass.methods).sort
end

#pbpasteObject



23
24
25
# File 'lib/libmatty/object.rb', line 23

def pbpaste
  `pbpaste`
end

#through(meth, *args) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/libmatty/object.rb', line 14

def through(meth, *args)
    if respond_to? meth
        send(meth, *args)
    else
        self
    end
end

#try(meth, *args) ⇒ Object



12
# File 'lib/libmatty/object.rb', line 12

def try(meth, *args); send(meth, *args) if respond_to? meth; end