Method: String#to_parse_class
- Defined in:
- lib/parse/model/model.rb
#to_parse_class(singularize: false) ⇒ String
Convert a string to a Parse class name. This method tries to find a responsible Parse::Object subclass that potentially matches the given string. If no match is found, it returns the camelized version of the string. This method is used internally for matching association attributes to registered Parse::Object subclasses. The method can also singularize the name before performing conversion.
194 195 196 197 198 199 200 |
# File 'lib/parse/model/model.rb', line 194 def to_parse_class(singularize: false) final_class = singularize ? self.singularize.camelize : self.camelize klass = Parse::Model.find_class(final_class) || Parse::Model.find_class(self) #handles the case that a class has a custom parse table final_class = klass.parse_class if klass.present? final_class end |