Module: AgentClient::Helper

Included in:
Segment
Defined in:
lib/agent_client/helper.rb

Overview

We would like to avoid depending on ActiveSupport

Instance Method Summary collapse

Instance Method Details

#underscore(string) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/agent_client/helper.rb', line 18

def underscore(string)
  word = string.to_s.dup
  word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
  word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
  word.tr!('-', '_')
  word.downcase!
  word
end