Module: Waves::Layers::Text::Inflect::English

Defined in:
lib/waves/layers/text/inflect/english.rb

Overview

Adds plural/singular methods for English to String

Class Method Summary collapse

Class Method Details

.included(app) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/waves/layers/text/inflect/english.rb', line 9

def self.included(app)

  require 'english/inflect'
          
  Waves::Resources::Mixin::ClassMethods.module_eval do
    def singular ; basename.snake_case.singular ; end
    def plural ; basename.snake_case.plural ; end
  end
  
  Waves::ResponseMixin.module_eval do
    def singular ; self.class.basename.snake_case.singular ; end
    def plural ; self.class.basename.snake_case.plural ; end
  end

  Waves::Resources::Mixin.module_eval do
    def singular ; self.class.singular ; end
    def plural ; self.class.plural ; end
  end

  Waves::Resources::Paths.module_eval do
    def resource ; self.class.resource.singular ; end
    def resources ; self.class.resource.plural ; end
  end

end