News for hackers. Stuff that matters.
Re:Responsible Monkeypatching in Ruby by goatlover on Friday August 27, 2021 @06:00AM (#28325965)
That looks like you're having to make a Weeks class just so you can do the same thing, instead of adding it to Integer and having it available on any int.
Re:Responsible Monkeypatching in Ruby by eloisius on Friday August 27, 2021 @06:11AM (#28326015)
In Ruby at least this example would just be an instance method named Weeks on the kernel class and it wouldn’t really be any more clunky to implement than the ActiveSupport flavor. However because Ruby you’re still reopening a class. You’re just adding a method to Kernel instead of Integer.
Re:Responsible Monkeypatching in Ruby by Fire-Dragon-DoL on Friday August 27, 2021 @08:55AM (#28327195)
That would just be a global method in ruby.

At the top of any file:

def Weeks(arg) end