Method: Adyen::Util#underscore

Defined in:
lib/adyen/util.rb

#underscore(identifier) ⇒ String

Returns the underscore version of a string.

Parameters:

  • identifier (:to_s)

    The identifier to turn to underscore notation.

Returns:

  • (String)

    The underscore version of the identifier provided.



65
66
67
68
69
70
# File 'lib/adyen/util.rb', line 65

def underscore(identifier)
  UNDERSCORE_EXCEPTIONS[identifier.to_s] || identifier.to_s
    .gsub(/([A-Z]{2,})([A-Z])/) { "#{$1.downcase}#{$2}" }
    .gsub(/(?!\A)([A-Z][a-z]*)/, '_\1')
    .downcase
end