class Onfleet::Util

Constants

SPECIAL_PARSE

Public Class Methods

constantize(class_name) click to toggle source
# File lib/onfleet-ruby/util.rb, line 7
def self.constantize(class_name)
  Object.const_get(class_name)
end
object_classes() click to toggle source
# File lib/onfleet-ruby/util.rb, line 25
def self.object_classes
  @object_classes ||= {
    'address'     => Address,
    'recipients'  => Recipient,
    'recipient'   => Recipient,
    'tasks'       => Task,
    'destination' => Destination,
    'vehicle'     => Vehicle
  }
end
to_camel_case_lower(str) click to toggle source
# File lib/onfleet-ruby/util.rb, line 21
def self.to_camel_case_lower(str)
  SPECIAL_PARSE[str] || str.camelize(:lower)
end
to_underscore(key) click to toggle source
# File lib/onfleet-ruby/util.rb, line 11
def self.to_underscore(key)
  key
    .to_s
    .gsub(/::/, '/')
    .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
    .gsub(/([a-z\d])([A-Z])/, '\1_\2')
    .tr('-', '_')
    .downcase
end