Method: Parse::Model.find_class
- Defined in:
- lib/parse/model/model.rb
.find_class(str) ⇒ Parse::Object
Find a Parse::Model subclass matching this type or Pares collection name. This helper method is useful to find the corresponding class ruby Parse::Object subclass that handles the provided parse class.
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/parse/model/model.rb', line 135 def self.find_class(str) return Parse::File if str == TYPE_FILE return Parse::GeoPoint if str == TYPE_GEOPOINT return Parse::Date if str == TYPE_DATE return Parse::Bytes if str == TYPE_BYTES # return Parse::User if str == "User" # return Parse::Installation if str == "Installation" str = str.to_s # Basically go through all Parse::Object subclasses and see who is has a parse_class # set to this string. We will cache the results for future use. @@model_cache[str] ||= Parse::Object.descendants.find do |f| f.parse_class == str || f.parse_class == "_#{str}" end end |