Module: FastUnderscore

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

Defined Under Namespace

Modules: AcronymRegex, AcronymUnderscoreRegex

Constant Summary collapse

VERSION =
'0.3.0'

Class Method Summary collapse

Class Method Details

.installObject

Depending on ‘ActiveSupport::VERSION`, `::install` determines the manner in which acronyms are handled, then it redefines the `ActiveSupport::Inflector::underscore` method to use the `FastUnderscore` native extension. It leaves the existing `ActiveSupport` monkeypatch on `String` that allows it to call into the newly redefined `Inflector` method.



12
13
14
15
16
17
18
19
20
# File 'lib/fast_underscore.rb', line 12

def self.install
  require 'active_support/version'

  if ActiveSupport::VERSION::MAJOR == 5 && ActiveSupport::VERSION::MINOR >= 2
    require 'fast_underscore/acronym_underscore_regex'
  else
    require 'fast_underscore/acronym_regex'
  end
end

.underscore(rb_string) ⇒ Object

A singleton method calls with a string that delegates to ‘str_underscore` to form an underscored, lowercase form from the expression in the string.



388
389
390
391
# File 'ext/fast_underscore/fast_underscore.c', line 388

static VALUE
rb_str_underscore(VALUE self, VALUE rb_string) {
  return str_underscore(rb_string);
}