Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq_unique_jobs/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#camelize(uppercase_first_letter = true) ⇒ Object


65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/sidekiq_unique_jobs/core_ext.rb', line 65

def camelize(uppercase_first_letter = true)
  string = self
  string = if uppercase_first_letter
             string.sub(/^[a-z\d]*/) { $&.capitalize }
           else
             string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase }
           end
  string.gsub!(%r{(?:_|(\/))([a-z\d]*)}i) do
    "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}"
  end
  string.gsub!(%r{/}, '::')
  string
end

#classifyObject


59
60
61
# File 'lib/sidekiq_unique_jobs/core_ext.rb', line 59

def classify
  camelize(sub(/.*\./, ''))
end