Module: GorillaPatch::Inflections

Defined in:
lib/gorilla_patch/inflections.rb

Overview

Inflections

Class Method Summary collapse

Class Method Details

.acronymsObject

Set of acronyms which can be modified externally



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

def acronyms
	@acronyms ||= Set.new(
		%w[API CLI DB DateTime FAQ HTML HTTP HTTPS ID IP JSON SEO SSL UTM XML]
	)
end

.acronyms_regexObject

Regular expression for detecting known acronyms



15
16
17
# File 'lib/gorilla_patch/inflections.rb', line 15

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

.from_dry_inflectorObject

Use inflections from DRY Inflector https://dry-rb.org/gems/dry-inflector/



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/gorilla_patch/inflections.rb', line 84

def self.from_dry_inflector
	@from_dry_inflector ||= Module.new do
		require 'dry/inflector'

		refine String do
			extend MethodsFromDryInflector

			define_methods_from_dry_inflector
		end
	end
end

.from_sequelObject

Use inflections from Sequel



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

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

		refine String do
			extend MethodsFromSequel

			define_methods_from_sequel
		end
	end
end