Module: Object::ObjectExtensions
- Included in:
- Object
- Defined in:
- lib/ragweed/utils.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.
- #through(meth, *args) ⇒ Object
- #try(meth, *args) ⇒ Object
Instance Method Details
#meta_def(name, &blk) ⇒ Object
9 |
# File 'lib/ragweed/utils.rb', line 9 def (name, &blk) { define_method name, &blk }; end |
#meta_eval(&blk) ⇒ Object
8 |
# File 'lib/ragweed/utils.rb', line 8 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.
7 |
# File 'lib/ragweed/utils.rb', line 7 def ; class << self; self; end; end |
#mymethods ⇒ Object
This is from Topher Cyll’s Stupd IRB tricks
21 22 23 |
# File 'lib/ragweed/utils.rb', line 21 def mymethods (self.methods - self.class.superclass.methods).sort end |
#through(meth, *args) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/ragweed/utils.rb', line 12 def through(meth, *args) if respond_to? meth send(meth, *args) else self end end |
#try(meth, *args) ⇒ Object
10 |
# File 'lib/ragweed/utils.rb', line 10 def try(meth, *args); send(meth, *args) if respond_to? meth; end |