Module: HelperMethods

Defined in:
lib/slim_form_object/helpers.rb

Instance Method Summary collapse

Instance Method Details

#class_name_if_module(string) ⇒ Object



7
8
9
10
# File 'lib/slim_form_object/helpers.rb', line 7

def class_name_if_module(string)
  return $1 if string =~ /^.+::(.+)$/
  string
end

#snake(string) ⇒ Object



2
3
4
5
# File 'lib/slim_form_object/helpers.rb', line 2

def snake(string)
  string.gsub!(/((\w)([A-Z]))/,'\2_\3')
  class_name_if_module(string.downcase)
end