Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit 4e337ec

Browse files
Merge pull request #40 from nodes-vapor/feature/access-levels
Use the types' accessLevels for extensions
2 parents 6c21f88 + af7f168 commit 4e337ec

7 files changed

Lines changed: 19 additions & 19 deletions

File tree

Controllers/RouteCollection.stencil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Vapor
66

77
extension {{ type.localName }}: RouteCollection {
8-
func build(_ builder: RouteBuilder) throws {
8+
{{ type.accessLevel }} func build(_ builder: RouteBuilder) throws {
99
builder.group("{{ type.annotations.group }}") { routes in
1010
{% for func in type.methods where func|annotated:"route" %}
1111
// {{ func.annotations.method|uppercase }} /{{ type.annotations.group }}{{ func.annotations.path }}

General/Enum.stencil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ extension RawStringConvertible {
5454
{% for enum in types.enums|!annotated:"ignore" where arguments.enumOptOut or enum.annotations.enum or enum.based.RawStringConvertible %}
5555

5656
extension {{ enum.name }} {
57-
static var all: [{{ enum.name }}] = [
57+
{{ type.accessLevel }} static var all: [{{ enum.name }}] = [
5858
{% for case in enum.cases %}
5959
.{{ case.name }},
6060
{% endfor %}
6161
]
6262

63-
static let allRaw = {{ enum.name }}.all.map { $0.rawValue }
63+
{{ type.accessLevel }} static let allRaw = {{ enum.name }}.all.map { $0.rawValue }
6464
}
6565

6666
{% endfor %}

Models/JSON.stencil

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import {{ var }}
1313
{% endif %}
1414

1515
extension {{ type.localName }} {
16-
internal enum JSONKeys {
16+
{{ type.accessLevel }} enum JSONKeys {
1717
{% for var in type.storedVariables|!annotated:"ignore"|!annotated:"ignoreJSONConvertible" %}
18-
static let {{ var.annotations.jsonKey|default:var.name }} = "{{ var.annotations.jsonKey|default:var.name }}"
18+
{{ type.accessLevel }} static let {{ var.annotations.jsonKey|default:var.name }} = "{{ var.annotations.jsonKey|default:var.name }}"
1919
{% endfor %}
2020
}
2121
}
@@ -24,7 +24,7 @@ extension {{ type.localName }} {
2424
// MARK: - JSONInitializable ({{ type.name }})
2525

2626
extension {{ type.localName }}: JSONInitializable {
27-
internal convenience init(json: JSON) throws {
27+
{{ type.accessLevel }} convenience init(json: JSON) throws {
2828
{% for var in type.storedVariables|!annotated:"ignore"|!annotated:"ignoreJSONConvertible"|!annotated:"ignoreJSONInitializable" %}
2929
let {{var.name}}: {{var.typeName}} = try json.get(JSONKeys.{{ var.annotations.jsonKey|default:var.name }})
3030
{% endfor %}
@@ -42,7 +42,7 @@ extension {{ type.localName }}: JSONInitializable {
4242
// MARK: - JSONRepresentable ({{ type.name }})
4343

4444
extension {{ type.localName }}: JSONRepresentable {
45-
internal func makeJSON() throws -> JSON {
45+
{{ type.accessLevel }} func makeJSON() throws -> JSON {
4646
var json = JSON()
4747

4848
try json.set({{ type.name }}.idKey, id)

Models/Model.stencil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
{% for type in types.based.Model|!protocol|annotated:"model" %}
44
// sourcery:inline:auto:{{ type.name }}.Models
5-
internal let storage = Storage()
5+
{{ type.accessLevel }} let storage = Storage()
66

7-
internal init(
7+
{{ type.accessLevel }} init(
88
{% for var in type.storedVariables|!annotated:"ignore" %}
99
{{ var.name }}: {{ var.typeName.description }}{% if var.isOptional %} = nil{% endif %}{% if not forloop.last %},{% endif %}
1010
{% endfor %}

Models/NodeRepresentable.stencil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import {{ var }}
1313
{% endif %}
1414

1515
extension {{ type.localName }}: NodeRepresentable {
16-
internal enum NodeKeys {
16+
{{ type.accessLevel }} enum NodeKeys {
1717
{% for var in type.storedVariables|!annotated:"ignore"|!annotated:"ignoreNodeRepresentable" %}
18-
static let {{ var.annotations.nodeKey|default:var.name }} = "{{ var.annotations.nodeKey|default:var.name }}"
18+
{{ type.accessLevel }} static let {{ var.annotations.nodeKey|default:var.name }} = "{{ var.annotations.nodeKey|default:var.name }}"
1919
{% endfor %}
2020
}
2121

2222
// MARK: - NodeRepresentable ({{ type.name }})
23-
func makeNode(in context: Context?) throws -> Node {
23+
{{ type.accessLevel }} func makeNode(in context: Context?) throws -> Node {
2424
var node = Node([:])
2525

2626
try node.set({{ type.name }}.idKey, id)

Models/Preparation.stencil

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import {{ var }}
1313
{% endif %}
1414

1515
extension {{ type.localName }}: Preparation {
16-
internal enum DatabaseKeys {
17-
static let id = {{ type.localName }}.idKey
16+
{{ type.accessLevel }} enum DatabaseKeys {
17+
{{ type.accessLevel }} static let id = {{ type.localName }}.idKey
1818
{% for var in type.storedVariables|!annotated:"ignore"|!annotated:"ignorePreparation" %}
19-
static let {{ var.annotations.databaseKey|default:var.name }} = "{{ var.annotations.databaseKey|default:var.name }}"
19+
{{ type.accessLevel }} static let {{ var.annotations.databaseKey|default:var.name }} = "{{ var.annotations.databaseKey|default:var.name }}"
2020
{% endfor %}
2121
}
2222

2323
// MARK: - Preparations ({{ type.name }})
24-
internal static func prepare(_ database: Database) throws {
24+
{{ type.accessLevel }} static func prepare(_ database: Database) throws {
2525
try database.create(self) {
2626
$0.id()
2727
{% for var in type.storedVariables|!annotated:"ignore"|!annotated:"ignorePreparation" %}
@@ -34,7 +34,7 @@ extension {{ type.localName }}: Preparation {
3434
{% endfor %}
3535
}
3636

37-
internal static func revert(_ database: Database) throws {
37+
{{ type.accessLevel }} static func revert(_ database: Database) throws {
3838
try database.delete(self)
3939
}
4040
}

Models/RowConvertible.stencil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import Fluent
77

88
extension {{ type.localName }}: RowConvertible {
99
// MARK: - RowConvertible ({{ type.name }})
10-
convenience internal init (row: Row) throws {
10+
convenience {{ type.accessLevel }} init (row: Row) throws {
1111
try self.init(
1212
{% for var in type.storedVariables|!annotated:"ignore"|!annotated:"ignoreRowConvertible" %}
1313
{{ var.name }}: row.get(DatabaseKeys.{{ var.annotations.databaseKey|default:var.name }}){% if not forloop.last %},{% endif %}
1414
{% endfor %}
1515
)
1616
}
1717

18-
internal func makeRow() throws -> Row {
18+
{{ type.accessLevel }} func makeRow() throws -> Row {
1919
var row = Row()
2020

2121
{% for var in type.storedVariables|!annotated:"ignore"|!annotated:"ignoreRowConvertible" %}

0 commit comments

Comments
 (0)