Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/parse/model/model.rb
Overview
Add extensions to the String class.
Instance Method Summary collapse
-
#columnize ⇒ String
This method returns a camel-cased version of the string with the first letter of the string in lower case.
-
#to_parse_class(singularize: false) ⇒ String
Convert a string to a Parse class name.
Instance Method Details
#columnize ⇒ String
This method returns a camel-cased version of the string with the first letter of the string in lower case. This is the standard naming convention for Parse columns and property fields. This has special exception to the string “id”, which returns “objectId”. This is the default name filtering method for all defined properties and query keys in Parse::Query.
187 188 189 190 191 |
# File 'lib/parse/model/model.rb', line 187 def columnize return Parse::Model::OBJECT_ID if self == Parse::Model::ID u = '_'.freeze (first == u ? sub(u,'') : self).camelize(:lower) end |
#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.
207 208 209 210 211 212 213 |
# File 'lib/parse/model/model.rb', line 207 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 |