Module: GorillaPatch::Inflections

Defined in:
lib/gorilla_patch/inflections.rb

Overview

Inflections

Class Method Summary collapse

Class Method Details

.acronymsObject



7
8
9
10
11
# File 'lib/gorilla_patch/inflections.rb', line 7

def acronyms
  @acronyms ||= %w[
    API DateTime FAQ HTML HTTP HTTPS ID IP JSON SEO SSL UTM XML
  ]
end

.acronyms_regexObject



13
14
15
# File 'lib/gorilla_patch/inflections.rb', line 13

def acronyms_regex
  /(?:(?<=([A-Z\d_]))|\b)((?i)#{acronyms.join('|')})(?=\b|[^a-z])/
end

.from_inflectoObject



65
66
67
68
69
# File 'lib/gorilla_patch/inflections.rb', line 65

def self.from_inflecto
  require 'inflecto-refinements'

  Inflecto::Refinements
end

.from_sequelObject



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/gorilla_patch/inflections.rb', line 51

def self.from_sequel
  @from_sequel ||= Module.new do
    require 'sequel'

    refine String do
      Sequel::Inflections.private_instance_methods.each do |method|
        define_method method do
          Sequel::Inflections.instance_method(method).bind(self).call(self)
        end
      end
    end
  end
end