lib/intercom/utils.rb in intercom-4.1.3 vs lib/intercom/utils.rb in intercom-4.2.0

- old
+ new

@@ -23,10 +23,14 @@ constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant end + def camelize(snake_cased_word) + snake_cased_word.split(/_/).map(&:capitalize).join + end + def resource_class_to_singular_name(resource_class) resource_name = resource_class.to_s.split('::')[-1] resource_name = maybe_underscore_name(resource_name) resource_name.downcase end @@ -38,11 +42,11 @@ def resource_class_to_collection_name(resource_class) Utils.pluralize(resource_class_to_singular_name(resource_class)) end def constantize_resource_name(resource_name) - class_name = Utils.singularize(resource_name.capitalize) + class_name = camelize Utils.singularize(resource_name.capitalize) define_lightweight_class(class_name) unless Intercom.const_defined?(class_name, false) namespaced_class_name = "Intercom::#{class_name}" constantize namespaced_class_name end @@ -63,9 +67,10 @@ def entity_key_from_type(type) return 'data' if type == 'list' is_list = type.split('.')[1] == 'list' entity_name = type.split('.')[0] + return Utils.pluralize(entity_name) if entity_name == 'event' is_list ? Utils.pluralize(entity_name) : entity_name end end end end