Module: Taketo::Support::Inflections

Extended by:
Inflections
Included in:
Inflections
Defined in:
lib/taketo/support/inflections.rb

Instance Method Summary collapse

Instance Method Details

#to_class(thing, nesting = Module.nesting.first || Object) ⇒ Object



19
20
21
# File 'lib/taketo/support/inflections.rb', line 19

def to_class(thing, nesting = Module.nesting.first || Object)
  nesting.const_get(class_name_from_string(to_singular(thing)))
end

#to_plural(thing) ⇒ Object



13
14
15
16
17
# File 'lib/taketo/support/inflections.rb', line 13

def to_plural(thing)
  str = name(thing)
  str << "s" unless plural?(str)
  str.to_sym
end

#to_singular(thing) ⇒ Object



7
8
9
10
11
# File 'lib/taketo/support/inflections.rb', line 7

def to_singular(thing)
  str = name(thing)
  str.chop! if plural?(str)
  str.to_sym
end