Class: Parse::Schema::SchemaInfo
- Inherits:
-
Object
- Object
- Parse::Schema::SchemaInfo
- Defined in:
- lib/parse/schema.rb
Overview
Represents schema information for a Parse class.
Instance Attribute Summary collapse
-
#class_level_permissions ⇒ Object
readonly
Returns the value of attribute class_level_permissions.
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#indexes ⇒ Object
readonly
Returns the value of attribute indexes.
Instance Method Summary collapse
-
#builtin? ⇒ Boolean
Check if this is a built-in Parse class.
-
#field_names ⇒ Array<String>
Get field names.
-
#field_type(field_name) ⇒ Symbol?
Get field type for a specific field.
-
#has_field?(field_name) ⇒ Boolean
Check if a field exists.
-
#initialize(data) ⇒ SchemaInfo
constructor
A new instance of SchemaInfo.
-
#pointer_target(field_name) ⇒ String?
Get pointer target class for a field.
-
#to_h ⇒ Hash
Get raw schema data.
Constructor Details
#initialize(data) ⇒ SchemaInfo
Returns a new instance of SchemaInfo.
199 200 201 202 203 204 205 |
# File 'lib/parse/schema.rb', line 199 def initialize(data) @class_name = data["className"] @fields = parse_fields(data["fields"] || {}) @indexes = data["indexes"] || {} @class_level_permissions = data["classLevelPermissions"] || {} @raw = data end |
Instance Attribute Details
#class_level_permissions ⇒ Object (readonly)
Returns the value of attribute class_level_permissions.
197 198 199 |
# File 'lib/parse/schema.rb', line 197 def @class_level_permissions end |
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
197 198 199 |
# File 'lib/parse/schema.rb', line 197 def class_name @class_name end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
197 198 199 |
# File 'lib/parse/schema.rb', line 197 def fields @fields end |
#indexes ⇒ Object (readonly)
Returns the value of attribute indexes.
197 198 199 |
# File 'lib/parse/schema.rb', line 197 def indexes @indexes end |
Instance Method Details
#builtin? ⇒ Boolean
Check if this is a built-in Parse class.
236 237 238 |
# File 'lib/parse/schema.rb', line 236 def builtin? @class_name.start_with?("_") end |
#field_names ⇒ Array<String>
Get field names.
209 210 211 |
# File 'lib/parse/schema.rb', line 209 def field_names @fields.keys end |
#field_type(field_name) ⇒ Symbol?
Get field type for a specific field.
216 217 218 |
# File 'lib/parse/schema.rb', line 216 def field_type(field_name) @fields[field_name.to_s]&.dig(:type) end |
#has_field?(field_name) ⇒ Boolean
Check if a field exists.
230 231 232 |
# File 'lib/parse/schema.rb', line 230 def has_field?(field_name) @fields.key?(field_name.to_s) end |
#pointer_target(field_name) ⇒ String?
Get pointer target class for a field.
223 224 225 |
# File 'lib/parse/schema.rb', line 223 def pointer_target(field_name) @fields[field_name.to_s]&.dig(:target_class) end |
#to_h ⇒ Hash
Get raw schema data.
242 243 244 |
# File 'lib/parse/schema.rb', line 242 def to_h @raw end |