I wish to put two aliases for one original method, but i don't see the ability of alias_method
to do multiple aliases at once, rather one by one.
So is there a possibility to change from this:
alias_method :aliased_first_method, :first_method
alias_method :aliased_first_method?, :first_method
to something like this:
alias_method [:aliased_first_method, :aliased_first_method?], :first_method
I'm not interested in creating custom methods.
I do not think there is a better way than just using each:
[:aliased_first_method, :aliased_first_method?].each{|ali| alias_method ali, :first_method}
Edit 2021 Ruby 2.7+
%i[aliased_first_method aliased_first_method?].each{ alias_method _1, :first_method]}
Looking at the docs and source of alias_method
, I would say that what you want is not possible without a custom method.
(Just had to answer my almost namesake :))
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