Module: Object::ObjectExtensions
- Included in:
- Object
- Defined in:
- lib/libmatty/object.rb
Instance Method Summary collapse
- #meta_def(name, &blk) ⇒ Object
- #meta_eval(&blk) ⇒ Object
-
#metaclass ⇒ Object
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.
-
#mymethods ⇒ Object
This is from Topher Cyll’s Stupd IRB tricks.
- #pbpaste ⇒ Object
- #through(meth, *args) ⇒ Object
- #try(meth, *args) ⇒ Object
Instance Method Details
#meta_def(name, &blk) ⇒ Object
11 |
# File 'lib/libmatty/object.rb', line 11 def (name, &blk) { define_method name, &blk }; end |
#meta_eval(&blk) ⇒ Object
10 |
# File 'lib/libmatty/object.rb', line 10 def (&blk) .instance_eval &blk; end |
#metaclass ⇒ Object
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 ; class << self; self; end; end |
#mymethods ⇒ Object
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 |
#pbpaste ⇒ Object
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 |