Closed jeremyevans closed 4 years ago
Upon further thought to this, I think it'd be better to use a guard clause instead of initializing a local variable.
def def_instance_delegator(accessor, method, ali = method)
gen = Forwardable._delegator_method(self, accessor, method, ali)
# If it's not a class or module, it's an instance
mod = Module === self ? self : singleton_class
unless RUBY_VERSION >= '2.7'
return mod.module_eval(&gen)
end
mod.send(:ruby2_keywords, ali)
end
@ashmaroli I don't think that will work on Ruby 2.7+.
I see.. Good to know that. Thanks.
This restores compatibility with previous versions. This behavior was previously undefined, but it makes sense for the name of the defined method to be returned.