Module: FastUnderscore

Defined in:
lib/fast_underscore.rb,
lib/fast_underscore/version.rb,
ext/fast_underscore/fast_underscore.c

Defined Under Namespace

Modules: ActiveSupportInflectorOldPatch, ActiveSupportInflectorPatch, ActiveSupportStringPatch, ActiveSupportedDelayedPatch

Constant Summary collapse

VERSION =
'0.3.2'

Class Method Summary collapse

Class Method Details

.active_supportObject

Depending on ActiveSupport::VERSION, ::active_support determines the manner in which acronyms are handled, then it redefines the ActiveSupport::Inflector::underscore method to use the FastUnderscore native extension.



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fast_underscore.rb', line 65

def self.active_support
  require 'active_support/version'
  gem_version = Gem::Version.new(ActiveSupport::VERSION::STRING)

  if gem_version >= Gem::Version.new('5.2.0')
    ActiveSupport::Inflector.prepend(ActiveSupportInflectorPatch)
  else
    ActiveSupport::Inflector.prepend(ActiveSupportInflectorOldPatch)
  end

  ActiveSupport::Inflector.alias_method(:as_underscore, :underscore)
  String.prepend(ActiveSupportStringPatch)
end

.underscore(string) ⇒ Object

FastUnderscore::underscore



333
334
335
# File 'ext/fast_underscore/fast_underscore.c', line 333

static VALUE fast_underscore(VALUE self, VALUE string) {
  return underscore(string);
}