# frozen_string_literal: true module WCC::Blogs module Utils module_function def camelcase(term) term .to_s .gsub(%r{(?:_|(/))([a-z\d]*)}) { "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}" } .gsub(%r{/}, '::') end def define_camelcase_alias(*underscore_method_names, &block) underscore_method_names.each do |method| attribute = camelcase(method) define_method(method) { instance_exec(attribute, &block) } alias_method attribute, method if attribute != method end end end end