Method: Kernel#qua_class
- Defined in:
- lib/core/facets/kernel/qua_class.rb
#qua_class(&block) ⇒ Object Also known as: quaclass
Easy access to an object qua class, otherwise known as the object’s singleton class. #qua_class can also take a block.
string = "Hello World"
string.qua_class do
def important
self + "!"
end
end
string.important #=> "Hello World!"
Yes, another one.
CREDIT: Trans
20 21 22 23 24 25 26 |
# File 'lib/core/facets/kernel/qua_class.rb', line 20 def qua_class(&block) if block_given? (class << self; self; end).class_eval(&block) else (class << self; self; end) end end |