Sha256: 93adf5a86c75eeb4fc3ae10753a563a55b90ce7aecf1876e5855d9ab8345ad11
Contents?: true
Size: 799 Bytes
Versions: 15
Compression:
Stored size: 799 Bytes
Contents
require "dry/inflector" module Voom # Helper module for converting symbol naming to string. # It provides common conversions for variable naming (snake_case) and class naming (class_name) module Symbol # Maps symbols to strings def sym_to_str(name) return name if name.is_a? ::String name.to_s end # Converts a namespaced string or symbol to snake_case def snake_case(str) inflector.underscore(sym_to_str(str).tr('.', '_')) end # Converts a namespaced symbol or string to a proper class name with modules def class_name(classname) classname = sym_to_str(classname) classname.split('.').map { |m| inflector.camelize(m) }.join('::') end private def inflector @inflector ||= Dry::Inflector.new end end end
Version data entries
15 entries across 15 versions & 1 rubygems