Module: Parse::API::Objects::ClassMethods

Defined in:
lib/parse/api/objects.rb

Overview

Class methods to be applied to Client

Instance Method Summary collapse

Instance Method Details

#uri_path(className, id = nil) ⇒ String

Get the API path for this class.

Parameters:

  • className (String)

    the name of the Parse collection.

  • id (String) (defaults to: nil)

    optional objectId to add at the end of the path.

Returns:

  • (String)

    the API uri path


34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/parse/api/objects.rb', line 34

def uri_path(className, id = nil)
  if className.is_a?(Parse::Pointer)
    id = className.id
    className = className.parse_class
  end
  uri = "#{CLASS_PATH_PREFIX}#{className}"
  class_prefix = className.downcase.to_sym
  if PREFIX_MAP.has_key?(class_prefix)
    uri = PREFIX_MAP[class_prefix]
  end
  id.present? ? "#{uri}/#{id}" : "#{uri}/"
end