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.
153 154 155 156 157 158 159 |
# File 'lib/parse/schema.rb', line 153 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.
151 152 153 |
# File 'lib/parse/schema.rb', line 151 def @class_level_permissions end |
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
151 152 153 |
# File 'lib/parse/schema.rb', line 151 def class_name @class_name end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
151 152 153 |
# File 'lib/parse/schema.rb', line 151 def fields @fields end |
#indexes ⇒ Object (readonly)
Returns the value of attribute indexes.
151 152 153 |
# File 'lib/parse/schema.rb', line 151 def indexes @indexes end |
Instance Method Details
#builtin? ⇒ Boolean
Check if this is a built-in Parse class.
190 191 192 |
# File 'lib/parse/schema.rb', line 190 def builtin? @class_name.start_with?("_") end |
#field_names ⇒ Array<String>
Get field names.
163 164 165 |
# File 'lib/parse/schema.rb', line 163 def field_names @fields.keys end |
#field_type(field_name) ⇒ Symbol?
Get field type for a specific field.
170 171 172 |
# File 'lib/parse/schema.rb', line 170 def field_type(field_name) @fields[field_name.to_s]&.dig(:type) end |
#has_field?(field_name) ⇒ Boolean
Check if a field exists.
184 185 186 |
# File 'lib/parse/schema.rb', line 184 def has_field?(field_name) @fields.key?(field_name.to_s) end |
#pointer_target(field_name) ⇒ String?
Get pointer target class for a field.
177 178 179 |
# File 'lib/parse/schema.rb', line 177 def pointer_target(field_name) @fields[field_name.to_s]&.dig(:target_class) end |
#to_h ⇒ Hash
Get raw schema data.
196 197 198 |
# File 'lib/parse/schema.rb', line 196 def to_h @raw end |