Module: Object::ObjectExtensions
- Included in:
- Object
- Defined in:
- lib/ruckus/extensions/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.
- #tap {|_self| ... } ⇒ Object
- #through(meth, *args) ⇒ Object
- #try(meth, *args) ⇒ Object
Instance Method Details
#meta_def(name, &blk) ⇒ Object
9 |
# File 'lib/ruckus/extensions/object.rb', line 9 def (name, &blk) { define_method name, &blk }; end |
#meta_eval(&blk) ⇒ Object
8 |
# File 'lib/ruckus/extensions/object.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/ruckus/extensions/object.rb', line 7 def ; class << self; self; end; end |
#tap {|_self| ... } ⇒ Object
20 21 22 23 |
# File 'lib/ruckus/extensions/object.rb', line 20 def tap yield(self) self end |
#through(meth, *args) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/ruckus/extensions/object.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/ruckus/extensions/object.rb', line 10 def try(meth, *args); send(meth, *args) if respond_to? meth; end |