lib/awrence/methods.rb
# Recursively converts Rubyish snake_case hash keys to camelBack JSON-style
# hash keys suitable for use with a JSON API.
#
Recursively converts Rubyish snake_case hash keys to camelBack JSON-style
hash keys suitable for use with a JSON API.
Recursively converts Rubyish snake_case hash keys to camelBack JSON - style hash keys suitable for use with a JSON API .
def camelize(snake_word, first_upper = true)
      if first_upper
        snake_word.to_s
          .gsub(/(?:^|_)([^_\s]+)/) { Awrence.acronyms[$1] || $1.capitalize }
          .gsub(%r|/([^/]*)|) { "::" + (Awrence.acronyms[$1] || $1.capitalize) }
      else
        parts = snake_word.split("_", 2)
        parts[0] << camelize(parts[1]) if parts.size > 1
        parts[0] || ""
      end
    end
def camelize ( snake_word , first_upper = true ) if first_upper snake_word . to_s . gsub ( / (?:^|_)([^_ \s ]+) / ) { Awrence . acronyms [ $1 ] || $1 . capitalize } . gsub ( %r| /([^/]*) | ) { "::" + ( Awrence . acronyms [ $1 ] || $1 . capitalize ) } else parts = snake_word . split ( "_" , 2 ) parts [ 0 ] << camelize ( parts [ 1 ] ) if parts . size > 1 parts [ 0 ] || "" end end
Recursively converts Rubyish snake_case hash keys to camelBack JSON-style
hash keys suitable for use with a JSON API.
Recursively converts Rubyish snake_case hash keys to camelBack JSON - style hash keys suitable for use with a JSON API .
snake_word
<not_specific>
first_upper
<not_specific>