Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/parse/model/file.rb

Overview

Adds extensions to Hash class.

Instance Method Summary collapse

Instance Method Details

#parse_file?Boolean

Determines if the hash contains Parse File json metadata fields. This is determined whether the key __type exists and is of type __File and whether the name field matches the File.basename of the url field.

Returns:

  • (Boolean)

    True if this hash contains Parse file metadata.



211
212
213
214
215
216
# File 'lib/parse/model/file.rb', line 211

def parse_file?
  url = self[Parse::File::FIELD_URL]
  name = self[Parse::File::FIELD_NAME]
  (count == 2 || self["__type"] == Parse::File.parse_class) &&
  url.present? && name.present? && name == ::File.basename(url)
end