diff --git a/CHANGELOG.md b/CHANGELOG.md
index 14f1d45..a2dc883 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,9 @@
* Improve error and warning messages when targetting an xcdatamodeld.
[Steven Watremez](https://github.com/StevenWatremez)
[#53](https://github.com/NijiDigital/gyro/pull/53)
+* Stop supporting `realmReadOnly` user info key.
+ [Steven Watremez](https://github.com/StevenWatremez)
+ [#57](https://github.com/NijiDigital/gyro/pull/57)
## 1.4.0
diff --git a/UserInfoKeys.md b/UserInfoKeys.md
index bce0be2..1a46723 100644
--- a/UserInfoKeys.md
+++ b/UserInfoKeys.md
@@ -9,7 +9,6 @@ Below are details about how to annotate your `.xcdatamodel` entities and attribu
- [Primary key](#primary-key)
- [Ignore attribute](#ignore-attribute)
-- [Read only](#read-only)
- [Inverse Relationships](#inverse-relationships)
- [Optionnals fields and wrapper types](#optionnals-fields-and-wrapper-types)
- [Support Annotations](#support-annotations)
@@ -143,56 +142,6 @@ final class Shop: Object {
----
-
-
-# Read only (DEPRECATED)
-
-
- Information about read only 'user info'
-On iOS/macOS, you can define attributes which are not persisted and whose value is computed dynamically.
-To do so, add the following 'user info' to **the attribute**
-
-| Key | Value |
-|-----|-------|
-| `realmReadOnly` | `the_code_source_to_generate` |
-
-
-__Example__: On the `readOnly` attribute of the `Shop` entity:
-
-![Read Only](documentation/read_only.png)
-
-
-
-📑 Sample of the generated code in Objective-C (iOS)
-
-```objc
-// DO NOT EDIT | Generated by gyro
-
-////////////////////////////////////////////////////////////////////////////////
-
-#pragma mark - Imports
-
-#import "RLMShop.h"
-
-////////////////////////////////////////////////////////////////////////////////
-
-#pragma mark - Implementation
-
-@implementation RLMShop
-
-#pragma mark - Superclass Overrides
-
-- (NSString *)readOnly
-{
- return self.name;
-}
-
-@end
-```
-
-
-
---
@@ -570,6 +519,8 @@ extension Shop: Mappable {
+---
+
## Combine JSONKeyPath and enums
diff --git a/documentation/read_only.png b/documentation/read_only.png
deleted file mode 100644
index 275d624..0000000
Binary files a/documentation/read_only.png and /dev/null differ
diff --git a/lib/gyro/parser/xcdatamodel/attribute.rb b/lib/gyro/parser/xcdatamodel/attribute.rb
index 23a92db..1d0fb7c 100644
--- a/lib/gyro/parser/xcdatamodel/attribute.rb
+++ b/lib/gyro/parser/xcdatamodel/attribute.rb
@@ -19,7 +19,7 @@ module XCDataModel
#
class Attribute
attr_accessor :entity_name, :name, :type, :optional, :indexed, :default
- attr_accessor :realm_ignored, :realm_read_only, :enum_type, :enum_values
+ attr_accessor :realm_ignored, :enum_type, :enum_values
attr_accessor :json_key_path, :json_values, :transformer, :comment, :support_annotation, :json_ignored
alias optional? optional
@@ -36,7 +36,6 @@ def initialize(attribute_xml, entity_name)
@default = attribute_xml.attributes['defaultValueString'].to_s
@type = attribute_xml.attributes['attributeType'].to_s.downcase.tr(' ', '_').to_sym
@realm_ignored = !Gyro::Parser::XCDataModel.user_info(attribute_xml, 'realmIgnored').empty?
- @realm_read_only = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'realmReadOnly')
@enum_type = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'enumType')
@enum_values = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'enumValues').split(',')
@json_key_path = Gyro::Parser::XCDataModel.user_info(attribute_xml, 'JSONKeyPath')
@@ -55,7 +54,7 @@ def to_h
'optional' => optional,
'indexed' => indexed,
'default' => default,
- 'realm_ignored' => realm_ignored, 'realm_read_only' => realm_read_only,
+ 'realm_ignored' => realm_ignored,
'enum_type' => enum_type, 'enum_values' => enum_values,
'json_key_path' => json_key_path, 'json_values' => json_values,
'json_ignored' => json_ignored,
@@ -71,10 +70,6 @@ def enum?
!@enum_type.empty?
end
- def read_only?
- !@realm_read_only.empty?
- end
-
def default?
!@default.empty?
end
diff --git a/lib/templates/android-java/inc/_attributes_enum.liquid b/lib/templates/android-java/inc/_attributes_enum.liquid
index b3b50a1..73f2a08 100644
--- a/lib/templates/android-java/inc/_attributes_enum.liquid
+++ b/lib/templates/android-java/inc/_attributes_enum.liquid
@@ -2,7 +2,7 @@
public static final class Attributes {
{%- for attribute in entity.attributes -%}
- {%- if attribute.realm_ignored == false or attribute.read_only == false -%}
+ {%- if attribute.realm_ignored == false -%}
{%- if attribute.comment.size > 0 %}
// {{ attribute.comment }}
{%- endif %}
diff --git a/lib/templates/android-java/inc/_attributes_getter_setter.liquid b/lib/templates/android-java/inc/_attributes_getter_setter.liquid
index 21d7ddc..8b1142e 100644
--- a/lib/templates/android-java/inc/_attributes_getter_setter.liquid
+++ b/lib/templates/android-java/inc/_attributes_getter_setter.liquid
@@ -1,6 +1,4 @@
{%- for attribute in entity.attributes %}
-
- {%- if attribute.realm_read_only.size == 0 %}
{%- comment %} ******* CONVERT TYPE CAPTURE ******* {% endcomment -%}
{%- capture visibility %}
@@ -12,7 +10,7 @@
{%- endcapture %}
{%- capture convert_type %}
- {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 -%}
+ {%- if attribute.enum_type.size > 0 -%}
String
{%- else -%}
{%- if params.use_wrappers.size > 0 and attribute.optional == true -%}
@@ -54,5 +52,4 @@
{{ visibility }} void set{{ name | titleize }}({%- if annotation.size > 0 %}{{ annotation | replace: "|"," " }} {% endif %}final {{ convert_type }} {{ name }}) {
this.{{ name }} = {{ name }};
}
- {%- endif %}
{%- endfor %}
\ No newline at end of file
diff --git a/lib/templates/android-java/inc/_attributes_properties.liquid b/lib/templates/android-java/inc/_attributes_properties.liquid
index 7c7474a..8ecf482 100644
--- a/lib/templates/android-java/inc/_attributes_properties.liquid
+++ b/lib/templates/android-java/inc/_attributes_properties.liquid
@@ -1,8 +1,7 @@
{% for attribute in entity.attributes -%}
- {%- if attribute.realm_read_only.size == 0 -%}
{%- comment %} ******* CONVERT TYPE CAPTURE ******* {% endcomment -%}
{%- capture convert_type -%}
- {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 -%}
+ {%- if attribute.enum_type.size > 0 -%}
String
{%- else -%}
{%- if params.use_wrappers == "true" and attribute.optional == true -%}
@@ -49,5 +48,4 @@
@android.support.annotation.{{ attribute.support_annotation }}
{%- endif %}
private {{ convert_type }} {{ name }}{{ default_value }};
- {%- endif -%}
{%- endfor -%}
\ No newline at end of file
diff --git a/lib/templates/android-java/inc/_enum_getter_setter.liquid b/lib/templates/android-java/inc/_enum_getter_setter.liquid
index d8f7e36..9fe789d 100644
--- a/lib/templates/android-java/inc/_enum_getter_setter.liquid
+++ b/lib/templates/android-java/inc/_enum_getter_setter.liquid
@@ -1,6 +1,6 @@
{%- for attribute in entity.attributes %}
- {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 %}
+ {%- if attribute.enum_type.size > 0 %}
{% if params.support_annotations.size > 0 %}
@android.support.annotation.Nullable
{%- capture annotation -%}@android.support.annotation.NonNull {% endcapture -%}
diff --git a/lib/templates/android-java/inc/_primitives.liquid b/lib/templates/android-java/inc/_primitives.liquid
index a8c67c2..0072ebc 100644
--- a/lib/templates/android-java/inc/_primitives.liquid
+++ b/lib/templates/android-java/inc/_primitives.liquid
@@ -1,5 +1,5 @@
{%- capture convert_type %}
- {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 -%}
+ {%- if attribute.enum_type.size > 0 -%}
String
{%- else -%}
{%- if params.use_wrappers.size > 0 and attribute.optional == true -%}
diff --git a/lib/templates/android-java/inc/_relationships_getter_setter.liquid b/lib/templates/android-java/inc/_relationships_getter_setter.liquid
index 5a80369..f8b3d22 100644
--- a/lib/templates/android-java/inc/_relationships_getter_setter.liquid
+++ b/lib/templates/android-java/inc/_relationships_getter_setter.liquid
@@ -1,7 +1,7 @@
{%- for relationship in entity.relationships %}
{%- if relationship.inverse == false %}
{%- capture relationship_type %}
- {%- if relationship.realm_read_only.size == 0 and relationship.enum_type.size > 0 -%}
+ {%- if relationship.enum_type.size > 0 -%}
String
{%- else %}
{%- if relationship.destination.size == 0 %}
diff --git a/lib/templates/android-java/inc/_relationships_properties.liquid b/lib/templates/android-java/inc/_relationships_properties.liquid
index 4761b27..0aec795 100644
--- a/lib/templates/android-java/inc/_relationships_properties.liquid
+++ b/lib/templates/android-java/inc/_relationships_properties.liquid
@@ -1,6 +1,6 @@
{%- for relationship in entity.relationships -%}
{%- capture relationship_type -%}
- {%- if relationship.realm_read_only.size == 0 and relationship.enum_type.size > 0 -%}
+ {%- if relationship.enum_type.size > 0 -%}
String
{%- else -%}
{%- if relationship.destination.size == 0 -%}
diff --git a/lib/templates/android-kotlin/inc/_attributes_enum.liquid b/lib/templates/android-kotlin/inc/_attributes_enum.liquid
index 35ad9ab..7281148 100644
--- a/lib/templates/android-kotlin/inc/_attributes_enum.liquid
+++ b/lib/templates/android-kotlin/inc/_attributes_enum.liquid
@@ -2,7 +2,7 @@
object Attributes {
{%- for attribute in entity.attributes -%}
- {%- if attribute.realm_ignored == false or attribute.read_only == false -%}
+ {%- if attribute.realm_ignored == false -%}
{%- if attribute.comment.size > 0 %}
// {{ attribute.comment }}
{%- endif %}
diff --git a/lib/templates/android-kotlin/inc/_attributes_properties.liquid b/lib/templates/android-kotlin/inc/_attributes_properties.liquid
index 65af484..8654298 100644
--- a/lib/templates/android-kotlin/inc/_attributes_properties.liquid
+++ b/lib/templates/android-kotlin/inc/_attributes_properties.liquid
@@ -1,8 +1,7 @@
{% for attribute in entity.attributes -%}
- {%- if attribute.realm_read_only.size == 0 -%}
{%- comment %} ******* CONVERT TYPE CAPTURE ******* {% endcomment -%}
{%- capture convert_type -%}
- {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 -%}
+ {%- if attribute.enum_type.size > 0 -%}
String
{%- else -%}
{%- include 'inc/type_converter' -%}
@@ -10,7 +9,7 @@
{%- endcapture -%}
{%- capture is_primitive %}
- {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 -%}
+ {%- if attribute.enum_type.size > 0 -%}
false
{%- else -%}
{%- include 'inc/type_primitives' -%}
@@ -56,5 +55,4 @@
@SerializedName("{{ attribute.json_key_path }}")
{%- endif %}
var {{ name }}: {{ convert_type }}{{ nullable_type }}{{ default_value }}
- {%- endif -%}
{%- endfor -%}
\ No newline at end of file
diff --git a/lib/templates/android-kotlin/inc/_enum_getter_setter.liquid b/lib/templates/android-kotlin/inc/_enum_getter_setter.liquid
index cdfc8ad..67ad680 100644
--- a/lib/templates/android-kotlin/inc/_enum_getter_setter.liquid
+++ b/lib/templates/android-kotlin/inc/_enum_getter_setter.liquid
@@ -1,6 +1,6 @@
{%- for attribute in entity.attributes %}
- {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 %}
+ {%- if attribute.enum_type.size > 0 %}
{%- assign name = attribute.name %}
fun get{{ name | titleize }}Enum(): {{ attribute.enum_type }}? = {{ attribute.enum_type }}.get({{ name }})
diff --git a/lib/templates/android-kotlin/inc/_primitives.liquid b/lib/templates/android-kotlin/inc/_primitives.liquid
index a8c67c2..0072ebc 100644
--- a/lib/templates/android-kotlin/inc/_primitives.liquid
+++ b/lib/templates/android-kotlin/inc/_primitives.liquid
@@ -1,5 +1,5 @@
{%- capture convert_type %}
- {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 -%}
+ {%- if attribute.enum_type.size > 0 -%}
String
{%- else -%}
{%- if params.use_wrappers.size > 0 and attribute.optional == true -%}
diff --git a/lib/templates/android-kotlin/inc/_relationships_properties.liquid b/lib/templates/android-kotlin/inc/_relationships_properties.liquid
index 869100d..ad2377c 100644
--- a/lib/templates/android-kotlin/inc/_relationships_properties.liquid
+++ b/lib/templates/android-kotlin/inc/_relationships_properties.liquid
@@ -1,6 +1,6 @@
{%- for relationship in entity.relationships -%}
{%- capture relationship_type -%}
- {%- if relationship.realm_read_only.size == 0 and relationship.enum_type.size > 0 -%}
+ {%- if relationship.enum_type.size > 0 -%}
String
{%- else -%}
{%- if relationship.destination.size == 0 -%}
diff --git a/lib/templates/swift3-variant/inc/_attributes_enum.liquid b/lib/templates/swift3-variant/inc/_attributes_enum.liquid
index 864dd6d..31446de 100644
--- a/lib/templates/swift3-variant/inc/_attributes_enum.liquid
+++ b/lib/templates/swift3-variant/inc/_attributes_enum.liquid
@@ -2,7 +2,7 @@
{% if entity.attributes.size > 0 %}
enum Attributes: String {
{%- for attribute in entity.attributes -%}
- {%- if attribute.realm_ignored or attribute.realm_read_only.size == 0 -%}
+ {%- if attribute.realm_ignored == false -%}
{%- if attribute.comment.size > 0 %}
/// {{ attribute.comment }}
{%- endif %}
diff --git a/lib/templates/swift3-variant/inc/_attributes_properties.liquid b/lib/templates/swift3-variant/inc/_attributes_properties.liquid
index 6abca1d..e6c2f60 100644
--- a/lib/templates/swift3-variant/inc/_attributes_properties.liquid
+++ b/lib/templates/swift3-variant/inc/_attributes_properties.liquid
@@ -9,18 +9,16 @@
{%- include 'inc/type_converter' -%}
{%- endcapture -%}
- {%- if attribute.realm_read_only.size == 0 -%}
- {%- if attribute.enum_values.size > 0 -%}
- {%- comment -%} ******* GENERATE ENUM ATTRIBUTE PROPERTY ******* {% endcomment -%}
- {%- include 'inc/enum_attribute_property' -%}
- {%- else -%}
- {%- if attribute.optional == true -%}
- {% comment -%} ******* GENERATE OPTIONAL ATTRIBUTE PROPERTY ******* {% endcomment -%}
- {%- include 'inc/optional_attribute_property' -%}
- {%- else -%}
- {%- comment -%} ******* GENERATE DEFAULT ATTRIBUTE PROPERTY ******* {% endcomment %}
+ {%- if attribute.enum_values.size > 0 -%}
+ {%- comment -%} ******* GENERATE ENUM ATTRIBUTE PROPERTY ******* {% endcomment -%}
+ {%- include 'inc/enum_attribute_property' -%}
+ {%- else -%}
+ {%- if attribute.optional == true -%}
+ {% comment -%} ******* GENERATE OPTIONAL ATTRIBUTE PROPERTY ******* {% endcomment -%}
+ {%- include 'inc/optional_attribute_property' -%}
+ {%- else -%}
+ {%- comment -%} ******* GENERATE DEFAULT ATTRIBUTE PROPERTY ******* {% endcomment %}
dynamic var {{ attribute.name }}: {{ convert_type }} = {{ default_value }}
- {%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
diff --git a/lib/templates/swift3/inc/_attributes_enum.liquid b/lib/templates/swift3/inc/_attributes_enum.liquid
index 6599068..78ae737 100644
--- a/lib/templates/swift3/inc/_attributes_enum.liquid
+++ b/lib/templates/swift3/inc/_attributes_enum.liquid
@@ -2,7 +2,7 @@
{% if entity.attributes.size > 0 %}
enum Attributes: String {
{%- for attribute in entity.attributes -%}
- {%- if attribute.realm_ignored or attribute.realm_read_only.size == 0 -%}
+ {%- if attribute.realm_ignored == false -%}
{%- if attribute.comment.size > 0 %}
/// {{ attribute.comment }}
{%- endif %}
diff --git a/lib/templates/swift3/inc/_attributes_properties.liquid b/lib/templates/swift3/inc/_attributes_properties.liquid
index 01b988f..52016f3 100644
--- a/lib/templates/swift3/inc/_attributes_properties.liquid
+++ b/lib/templates/swift3/inc/_attributes_properties.liquid
@@ -9,17 +9,17 @@
{%- include 'inc/type_converter' -%}
{%- endcapture -%}
- {%- if attribute.realm_read_only.size == 0 -%}
- {%- if attribute.enum_values.size > 0 -%}
- {%- comment -%} ******* GENERATE ENUM ATTRIBUTE PROPERTY ******* {% endcomment -%}
- {%- include 'inc/enum_attribute_property' -%}
- {%- else -%}{%- if attribute.optional == true -%}
+ {%- if attribute.enum_values.size > 0 -%}
+ {%- comment -%} ******* GENERATE ENUM ATTRIBUTE PROPERTY ******* {% endcomment -%}
+ {%- include 'inc/enum_attribute_property' -%}
+ {%- else -%}
+ {%- if attribute.optional == true -%}
{% comment -%} ******* GENERATE OPTIONAL ATTRIBUTE PROPERTY ******* {% endcomment -%}
{%- include 'inc/optional_attribute_property' -%}
{%- else -%}
{%- comment -%} ******* GENERATE DEFAULT ATTRIBUTE PROPERTY ******* {% endcomment %}
@objc dynamic var {{ attribute.name }}: {{ convert_type }} = {{ default_value }} {%- if attribute.name == entity.identity_attribute %} /* Primary Key */{% endif -%}
- {%- endif -%}{%- endif -%}
+ {%- endif -%}
{%- endif -%}
{%- endfor -%}
diff --git a/spec/fixtures/java/ignored/Shop.java b/spec/fixtures/java/ignored/Shop.java
index 4517e5f..d967dd6 100644
--- a/spec/fixtures/java/ignored/Shop.java
+++ b/spec/fixtures/java/ignored/Shop.java
@@ -11,7 +11,6 @@ public class Shop extends RealmObject {
public static final class Attributes {
public static final String NAME = "name";
- public static final String READ_ONLY = "readOnly";
private Attributes() {
// Hide constructor
diff --git a/spec/fixtures/kotlin/ignored/Shop.kt b/spec/fixtures/kotlin/ignored/Shop.kt
index 0dbbeaf..6f85296 100644
--- a/spec/fixtures/kotlin/ignored/Shop.kt
+++ b/spec/fixtures/kotlin/ignored/Shop.kt
@@ -11,7 +11,6 @@ open class Shop : RealmObject() {
object Attributes {
const val NAME: String = "name"
- const val READ_ONLY: String = "readOnly"
}
object Relationships {
diff --git a/spec/fixtures/swift/ignored/Shop.swift b/spec/fixtures/swift/ignored/Shop.swift
index 576c497..c2fc45e 100644
--- a/spec/fixtures/swift/ignored/Shop.swift
+++ b/spec/fixtures/swift/ignored/Shop.swift
@@ -6,8 +6,6 @@ import Foundation
final class Shop: Object {
enum Attributes: String {
- case ignored = "ignored"
- case ignored2 = "ignored2"
case name = "name"
}
diff --git a/spec/fixtures/xcdatamodel/ignored.xcdatamodel/contents b/spec/fixtures/xcdatamodel/ignored.xcdatamodel/contents
index 8b12ff2..0275102 100644
--- a/spec/fixtures/xcdatamodel/ignored.xcdatamodel/contents
+++ b/spec/fixtures/xcdatamodel/ignored.xcdatamodel/contents
@@ -1,5 +1,5 @@
-
+
@@ -23,17 +23,12 @@
-
-
-
-
-
-
+
\ No newline at end of file