lib/hanami/utils/inflector.rb in hanami-utils-1.1.0.beta1 vs lib/hanami/utils/inflector.rb in hanami-utils-1.1.0.beta2
- old
+ new
@@ -224,11 +224,12 @@
'sheep' => 'sheep',
'species' => 'species',
'police' => 'police',
# regressions
# https://github.com/hanami/utils/issues/106
- 'album' => 'albums'
+ 'album' => 'albums',
+ 'area' => 'areas'
)
# Irregular rules for singulars
#
# @since 0.6.0
@@ -265,12 +266,15 @@
'series' => 'series',
'sheep' => 'sheep',
'species' => 'species',
'police' => 'police',
# fallback
+ 'areas' => 'area',
'hives' => 'hive',
- 'phases' => 'phase'
+ 'phases' => 'phase',
+ 'exercises' => 'exercise',
+ 'releases' => 'release'
)
# Block for custom inflection rules.
#
# @param [Proc] blk custom inflections
@@ -307,11 +311,20 @@
#
# Hanami::Utils::Inflector.inflections do
# exception 'alga', 'algae'
# end
def self.exception(singular, plural)
+ add_to_inflecto(singular, plural)
singulars.add(plural, singular)
plurals.add(singular, plural)
+ end
+
+ # Since ROM uses Inflecto for it inferences, we need to add an exception to it
+ # when one is registered against our Inflector.
+ # @api private
+ def self.add_to_inflecto(singular, plural)
+ return unless defined? Inflecto
+ Inflecto.inflections.irregular(singular, plural)
end
# Add an uncountable word
#
# @param [Array<String>] words