Module: Nuvemshop::Inflections

Defined in:
lib/nuvemshop/inflections/pascal_case.rb,
lib/nuvemshop/inflections/infer_key_class_name.rb

Class Method Summary collapse

Class Method Details

.infer_key_class_name(klass, key) ⇒ Object



3
4
5
6
7
# File 'lib/nuvemshop/inflections/infer_key_class_name.rb', line 3

def self.infer_key_class_name(klass, key)
  Object.const_get(klass.to_s.split('::')[0..-2].push(pascal_case(key)).join('::'))
rescue NameError
  Nuvemshop::GenericModel
end

.pascal_case(key) ⇒ Object



3
4
5
# File 'lib/nuvemshop/inflections/pascal_case.rb', line 3

def self.pascal_case(key)
  key.split('_').map(&:capitalize).join
end