Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
drop realmrReadOnly user info key support
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenWatremez committed Mar 15, 2018
1 parent c68e565 commit e26a2fb
Show file tree
Hide file tree
Showing 26 changed files with 74 additions and 119 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## master
* drop realmReadOnly use info key support.
[Steven Watremez](https://github.com/StevenWatremez)
[#58](https://github.com/NijiDigital/gyro/pull/58)

## 1.4.0

* Order the Primary Key (identity attribute) first when generating the class for the entity.
Expand Down
54 changes: 2 additions & 52 deletions UserInfoKeys.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -142,57 +141,6 @@ final class Shop: Object {
```
</details>


---

<a name="read-only"></a>
# Read only (DEPRECATED)

<details>
<summary> Information about read only 'user info'</summary>
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)
</details>

<details>
<summary>📑 Sample of the generated code in Objective-C (iOS)</summary>

```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
```
</details>
---

<a name="inverse-relationships"></a>
Expand Down Expand Up @@ -570,6 +518,8 @@ extension Shop: Mappable {

</details>

---

<a name="combine-jsonkeypath-and-enums"></a>
## Combine JSONKeyPath and enums

Expand Down
2 changes: 1 addition & 1 deletion lib/templates/swift3-variant/inc/_attributes_enum.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{%- if attribute.comment.size > 0 %}
/** {{ attribute.comment }} **/
{%- endif %}
case {{ attribute.name }} = "{{ attribute.name | escape_quotes }}"
static let {{ attribute.name }} = "{{ attribute.name | escape_quotes }}"
{%- endif %}
{%- endfor %}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{%- endif -%}
{%- endcapture -%}
{%- assign relationship_name = relationship_name %}
case {{ relationship_name | uncapitalize }} = "{{ relationship_name | escape_quotes }}"
static let {{ relationship_name | uncapitalize }} = "{{ relationship_name | escape_quotes }}"
{%- endfor %}
}
{% endif -%}
2 changes: 1 addition & 1 deletion lib/templates/swift3/inc/_attributes_enum.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{%- if attribute.comment.size > 0 %}
/** {{ attribute.comment }} **/
{%- endif %}
case {{ attribute.name }} = "{{ attribute.name | escape_quotes }}"{% if attribute.name == entity.identity_attribute %} /* Primary Key */{% endif %}
static let {{ attribute.name }} = "{{ attribute.name | escape_quotes }}"{% if attribute.name == entity.identity_attribute %} /* Primary Key */{% endif %}
{%- endif %}
{%- endfor %}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/templates/swift3/inc/_relationships_enum.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{%- endif -%}
{%- endcapture -%}
{%- assign relationship_name = relationship_name %}
case {{ relationship_name | uncapitalize }} = "{{ relationship_name | escape_quotes }}"
static let {{ relationship_name | uncapitalize }} = "{{ relationship_name | escape_quotes }}"
{%- endfor %}
}
{% endif -%}
16 changes: 8 additions & 8 deletions spec/fixtures/swift/default/Shop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import Foundation
final class Shop: Object {

enum Attributes: String {
case active = "active"
case budget = "budget"
case isOpen = "isOpen"
case name = "name"
case numberOfArrivals = "numberOfArrivals"
case numberOfProducts = "numberOfProducts"
case promo = "promo"
case slogan = "slogan"
static let active = "active"
static let budget = "budget"
static let isOpen = "isOpen"
static let name = "name"
static let numberOfArrivals = "numberOfArrivals"
static let numberOfProducts = "numberOfProducts"
static let promo = "promo"
static let slogan = "slogan"
}

@objc dynamic var active: Bool = true
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/swift/enum/Shop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Foundation
final class Shop: Object {

enum Attributes: String {
case name = "name"
case optionalValue = "optionalValue"
case type = "type"
static let name = "name"
static let optionalValue = "optionalValue"
static let type = "type"
}

@objc dynamic var name: String = ""
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/swift/ignored/Owner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import Foundation
final class Owner: Object {

enum Attributes: String {
case name = "name"
static let name = "name"
}

enum Relationships: String {
case shop = "shop"
static let shop = "shop"
}

@objc dynamic var name: String?
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/swift/ignored/Product.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Foundation
final class Product: Object {

enum Relationships: String {
case shop = "shop"
static let shop = "shop"
}

@objc dynamic var shop: Shop?
Expand Down
10 changes: 5 additions & 5 deletions spec/fixtures/swift/ignored/Shop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import Foundation
final class Shop: Object {

enum Attributes: String {
case ignored = "ignored"
case ignored2 = "ignored2"
case name = "name"
static let ignored = "ignored"
static let ignored2 = "ignored2"
static let name = "name"
}

enum Relationships: String {
case owner = "owner"
case products = "products"
static let owner = "owner"
static let products = "products"
}

@objc dynamic var ignored: String = ""
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/swift/inverse/Dog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import Foundation
final class Dog: Object {

enum Attributes: String {
case age = "age"
case name = "name"
static let age = "age"
static let name = "name"
}

@objc dynamic var age: Int16 = 0
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/swift/inverse/Person.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Foundation
final class Person: Object {

enum Relationships: String {
case dogs = "dogs"
static let dogs = "dogs"
}

let dogs = List<Dog>()
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/swift/optional/FidelityCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import Foundation
final class FidelityCard: Object {

enum Attributes: String {
case identifier = "identifier"
case points = "points"
static let identifier = "identifier"
static let points = "points"
}

enum Relationships: String {
case user = "user"
static let user = "user"
}

@objc dynamic var identifier: Int16 = 0
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/swift/optional/Product.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Foundation
final class Product: Object {

enum Attributes: String {
case brand = "brand"
case name = "name"
case price = "price"
static let brand = "brand"
static let name = "name"
static let price = "price"
}

@objc dynamic var brand: String?
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/swift/optional/Shop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import Foundation
final class Shop: Object {

enum Attributes: String {
case name = "name"
static let name = "name"
}

enum Relationships: String {
case products = "products"
static let products = "products"
}

@objc dynamic var name: String = ""
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/swift/optional/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import Foundation
final class User: Object {

enum Attributes: String {
case birthday = "birthday"
case name = "name"
static let birthday = "birthday"
static let name = "name"
}

enum Relationships: String {
case fidelityCard = "fidelityCard"
static let fidelityCard = "fidelityCard"
}

@objc dynamic var birthday: Date = Date()
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/swift/primary/FidelityCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import Foundation
final class FidelityCard: Object {

enum Attributes: String {
case identifier = "identifier" /* Primary Key */
case points = "points"
static let identifier = "identifier" /* Primary Key */
static let points = "points"
}

enum Relationships: String {
case user = "user"
static let user = "user"
}

@objc dynamic var identifier: Int16 = 0 /* Primary Key */
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/swift/primary/Product.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Foundation
final class Product: Object {

enum Attributes: String {
case name = "name" /* Primary Key */
case brand = "brand"
case price = "price"
static let name = "name" /* Primary Key */
static let brand = "brand"
static let price = "price"
}

@objc dynamic var name: String = "" /* Primary Key */
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/swift/primary/Shop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import Foundation
final class Shop: Object {

enum Attributes: String {
case name = "name" /* Primary Key */
static let name = "name" /* Primary Key */
}

enum Relationships: String {
case products = "products"
static let products = "products"
}

@objc dynamic var name: String = "" /* Primary Key */
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/swift/primary/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import Foundation
final class User: Object {

enum Attributes: String {
case name = "name" /* Primary Key */
case birthday = "birthday"
static let name = "name" /* Primary Key */
static let birthday = "birthday"
}

enum Relationships: String {
case fidelityCard = "fidelityCard"
static let fidelityCard = "fidelityCard"
}

@objc dynamic var name: String = "" /* Primary Key */
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/swift/realm/FidelityCard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import Foundation
final class FidelityCard: Object {

enum Attributes: String {
case identifier = "identifier"
case points = "points"
static let identifier = "identifier"
static let points = "points"
}

enum Relationships: String {
case user = "user"
static let user = "user"
}

@objc dynamic var identifier: Int16 = 0
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/swift/realm/Product.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import Foundation
final class Product: Object {

enum Attributes: String {
case brand = "brand"
case name = "name"
case price = "price"
static let brand = "brand"
static let name = "name"
static let price = "price"
}

@objc dynamic var brand: String = ""
Expand Down
4 changes: 2 additions & 2 deletions spec/fixtures/swift/realm/Shop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import Foundation
final class Shop: Object {

enum Attributes: String {
case name = "name"
static let name = "name"
}

enum Relationships: String {
case products = "products"
static let products = "products"
}

@objc dynamic var name: String = ""
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/swift/realm/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import Foundation
final class User: Object {

enum Attributes: String {
case birthday = "birthday"
case name = "name"
static let birthday = "birthday"
static let name = "name"
}

enum Relationships: String {
case fidelityCard = "fidelityCard"
static let fidelityCard = "fidelityCard"
}

@objc dynamic var birthday: Date = Date()
Expand Down
Loading

0 comments on commit e26a2fb

Please sign in to comment.