Sha256: d051ed1d807125ea39a65c440bfc0e2e3c57ee96d276ad20c9e2a62ed4647b80
Contents?: true
Size: 590 Bytes
Versions: 2
Compression:
Stored size: 590 Bytes
Contents
# frozen_string_literal: true require 'fast_underscore/version' require 'fast_underscore/fast_underscore' if defined?(ActiveSupport) String.prepend(Module.new do def underscore return self unless /[A-Z-]|::/.match?(self) acronyms = ActiveSupport::Inflector.inflections.acronym_regex dup.gsub!(/(?:(?<=([A-Za-z\d]))|\b)(#{acronyms})(?=\b|[^a-z])/) do "#{$1 && '_'}#{$2.downcase}" end FastUnderscore.underscore(self) end end) else String.prepend(Module.new do def underscore FastUnderscore.underscore(self) end end) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fast_underscore-0.0.2 | lib/fast_underscore.rb |
fast_underscore-0.0.1 | lib/fast_underscore.rb |