Module: Motor::BuildSchema::Utils

Defined in:
lib/motor/build_schema/utils.rb

Constant Summary collapse

ABBREVIATIONS =
{
  'Id' => 'ID',
  'Uuid' => 'UUID',
  'Url' => 'URL',
  'Iso' => 'ISO',
  'vip' => 'VIP',
  'Ip' => 'IP',
  'Zip' => 'ZIP'
}.freeze

Class Method Summary collapse

Class Method Details

.classify_slug(slug) ⇒ Object


22
23
24
# File 'lib/motor/build_schema/utils.rb', line 22

def classify_slug(slug)
  slug.singularize.gsub('__', '/').classify.constantize
end

.humanize_column_name(column_name) ⇒ Object


26
27
28
# File 'lib/motor/build_schema/utils.rb', line 26

def humanize_column_name(column_name)
  ABBREVIATIONS.fetch(column_name, column_name.humanize)
end

.slugify(model) ⇒ Object


18
19
20
# File 'lib/motor/build_schema/utils.rb', line 18

def slugify(model)
  model.name.underscore.pluralize.gsub('/', '__')
end