Reputation: 43
I was reading the ActiveSupport core_ext source, and saw that it directly open and extend the core ruby class, e.g: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/string/conversions.rb
. Doesn't that make it harder for us to know wether some method is from activesupport or actually provided by ruby itself (e.g via Method#owner
)?
Why doesn't it use something like prepending/including a module to give its added functionality? E.g:
module StringConversionExtension
def to_time
# some implementation
end
end
String.prepend(StringExtension)
Is there any historical/performance reason the implementation is as it is now?
Upvotes: 1
Views: 144
Reputation: 14520
Why doesn't it use something like prepending/including a module to give its added functionality? E.g:
Possibly to either:
Upvotes: 0