Is there any function or way to simulate this with in ruby?
It helps you to organize the code that acts over the same object, something like:
with(callDao) {
whenever(deleteAll()).thenComplete()
whenever(insertAll(any())).thenComplete()
}
vs
whenever(callDao.deleteAll()).thenComplete()
whenever(callDao.insertAll(any())).thenComplete()
Yes, you can build your own with using instance_eval.
def with(obj, &block)
obj.instance_eval(&block)
end
with(" banana ") {
puts strip
puts reverse
}
Output:
banana
ananab
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With