You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2010/12/08 13:34:22 UTC

[PATCH core 1/4] Fixed pluralization/singularization for Strings in Rabbit

From: Michal Fojtik <mf...@redhat.com>

---
 server/lib/sinatra/rabbit.rb |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/server/lib/sinatra/rabbit.rb b/server/lib/sinatra/rabbit.rb
index 05bd6c5..76c9031 100644
--- a/server/lib/sinatra/rabbit.rb
+++ b/server/lib/sinatra/rabbit.rb
@@ -259,11 +259,19 @@ class String
   end
 
   def pluralize
-    self + "s"
+    if self =~ /ss/
+      self + "es"
+    else
+      self + "s"
+    end
   end
 
   def singularize
-    self.gsub(/s$/, '')
+    if self =~ /sses$/
+      self.gsub(/es$/, '')
+    else
+      self.gsub(/s$/, '')
+    end
   end
 
   def underscore
-- 
1.7.3.2