Module: Contentful::Support

Defined in:
lib/contentful/support.rb

Overview

Utility methods used by the contentful gem

Class Method Summary (collapse)

Class Method Details

+ (String) snakify(object)

Transforms CamelCase into snake_case (taken from zucker)

Parameters:

  • object (String)

    camelCaseName

Returns:

  • (String)

    snake_case_name



10
11
12
13
# File 'lib/contentful/support.rb', line 10

def snakify(object)
  snake = String(object).gsub(/(?<!^)[A-Z]/) { "_#{$&}" }
  snake.downcase
end