Sha256: 1996d516d3e6cf11a6cb14ddf14fba8d3df01f07523ad1d99feb5f7627b0b6f2
Contents?: true
Size: 673 Bytes
Versions: 1
Compression:
Stored size: 673 Bytes
Contents
# frozen_string_literal: true module FastUnderscore # Uses ActiveSupport's `acronym_underscore_regex` method for replacing # acronyms within strings that need to be underscored. module AcronymUnderscoreRegex def underscore return self unless /[A-Z-]|::/.match?(self) response = dup acronyms = ActiveSupport::Inflector.inflections.acronyms_underscore_regex response.gsub!(acronyms) { "#{$1 && '_'}#{$2.downcase}" } FastUnderscore.underscore(response) end end end String.prepend(FastUnderscore::AcronymUnderscoreRegex) class << ActiveSupport::Inflector define_method(:underscore, &FastUnderscore.method(:underscore)) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fast_underscore-0.1.0 | lib/fast_underscore/ext/acronym_underscore_regex.rb |