From 72ae195c4195dc01885d96d8b1caededa5384c9b Mon Sep 17 00:00:00 2001 From: Andrey Chernih <andrey.chernih@gmail.com> Date: Tue, 9 Sep 2014 15:48:38 +0400 Subject: [PATCH] Only load Sequel's inflector as a last resort It monkey-patches String thus breaking our app: Before adding state_machine gem: 'filter_metadata'.pluralize => 'filter_metadata' After adding state_machine gem: 'filter_metadata'.pluralize => 'filter_metadatas' --- lib/state_machine/integrations/sequel.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/state_machine/integrations/sequel.rb b/lib/state_machine/integrations/sequel.rb index b7d1887e..d520e535 100644 --- a/lib/state_machine/integrations/sequel.rb +++ b/lib/state_machine/integrations/sequel.rb @@ -310,8 +310,14 @@ def reset(object) # Pluralizes the name using the built-in inflector def pluralize(word) - load_inflector - super + word = word.to_s + + if word.respond_to?(:pluralize) + word.pluralize + else + load_inflector + super + end end protected