Module: Verquest::Base::HelperClassMethods Private

Included in:
Verquest::Base, Configuration
Defined in:
lib/verquest/base/helper_class_methods.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Helper methods for Verquest::Base class methods

This module contains utility methods for working with string and hash transformations. It provides methods for converting between different naming conventions (snake_case to camelCase) which is particularly useful when working with JSON Schema properties.

Instance Method Summary collapse

Instance Method Details

#camelize(hash) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts hash keys from snake_case to camelCase format

Transforms all keys in the given hash from snake_case (e.g., “max_length”) to camelCase (e.g., “maxLength”) format, which is commonly used in JSON Schema. The transformation happens in place, modifying the original hash.

Parameters:

  • hash (Hash)

    The hash containing snake_case keys

Returns:

  • (Hash)

    The same hash with keys transformed to camelCase



21
22
23
# File 'lib/verquest/base/helper_class_methods.rb', line 21

def camelize(hash)
  hash.transform_keys! { |key| snake_to_camel(key.to_s).to_sym }
end

#snake_to_camel(str) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts a snake_case string to camelCase

Takes a string in snake_case format (e.g., “max_length”) and converts it to camelCase format (e.g., “maxLength”) by capitalizing each word after the first one and removing underscores.

Parameters:

  • str (String)

    The snake_case string to convert

Returns:

  • (String)

    The converted camelCase string



33
34
35
# File 'lib/verquest/base/helper_class_methods.rb', line 33

def snake_to_camel(str)
  str.split("_").inject { |memo, word| memo + word.capitalize }
end