Skip to content

Commit b811ca9

Browse files
author
Florian Rieger
authored
Merge pull request #16 from AppCron/swift3.1
Swift3.1
2 parents 12b5f6d + 2f86e51 commit b811ca9

File tree

7 files changed

+34
-39
lines changed

7 files changed

+34
-39
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# ACInteractor
2-
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://raw.githubusercontent.com/appcron/acinteractor/master/LICENSE)
2+
[![License](https://img.shields.io/badge/swift-3.1-orange.svg)](https://swift.org/blog/swift-3-1-released/)
3+
[![License](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](https://raw.githubusercontent.com/appcron/acinteractor/master/LICENSE)
34

45
Swift Package for a Use Case centric architecture as proposed by Robert C. Martin and others.
56

Sources/InteractorExecuter.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
import Foundation
22

3-
open class InteractorExecuter {
3+
class InteractorExecuter {
44

5-
fileprivate var interactors = Dictionary<String, AnyObject>()
5+
private var interactors = Dictionary<String, AnyObject>()
66

77
// MARK: Register
88

9-
open func registerInteractor<InteractorProtocol: Interactor, Response>
9+
func registerInteractor<InteractorProtocol: Interactor, Response>
1010
(_ interactor: InteractorProtocol, request: InteractorRequest<Response>)
1111
{
1212
let key = String(describing: request)
13-
self.interactors[key] = InteractorWrapper(interactor: interactor)
13+
interactors[key] = InteractorWrapper(interactor: interactor)
1414
}
1515

1616
// MARK: Execute
1717

18-
open func execute<Request: ErrorRequest>(_ request: Request) {
18+
func execute<Request: ErrorRequest>(_ request: Request) {
1919
let key = String(describing: request)
2020
let optionalValue = interactors[key]
2121

2222
guard let value = optionalValue else {
23-
self.fireIntactorNotRegisterdError(request)
23+
fireIntactorNotRegisterdError(request)
2424
return
2525
}
2626

2727
guard let wrapper = value as? InteractorWrapper<Request> else {
28-
self.fireIntactorMismatchError(request)
28+
fireIntactorMismatchError(request)
2929
return
3030
}
3131

@@ -34,19 +34,19 @@ open class InteractorExecuter {
3434

3535
// MARK: Error Handling
3636

37-
fileprivate func fireErrorOnRequest(_ request: ErrorRequest, errorMessage: String) {
37+
private func fireErrorOnRequest(_ request: ErrorRequest, errorMessage: String) {
3838
let error = InteractorError(message: errorMessage)
3939
request.onError?(error)
4040
}
4141

42-
fileprivate func fireIntactorNotRegisterdError(_ request: ErrorRequest) {
42+
private func fireIntactorNotRegisterdError(_ request: ErrorRequest) {
4343
let message = "ACInteractor.ACInteractorExcuter: No Interactor is registered for this request!"
44-
self.fireErrorOnRequest(request, errorMessage: message)
44+
fireErrorOnRequest(request, errorMessage: message)
4545
}
4646

47-
fileprivate func fireIntactorMismatchError(_ request: ErrorRequest) {
47+
private func fireIntactorMismatchError(_ request: ErrorRequest) {
4848
let message = "ACInteractor.ACInteractorExcuter: Request does not match execute function of registered Interactor!"
49-
self.fireErrorOnRequest(request, errorMessage: message)
49+
fireErrorOnRequest(request, errorMessage: message)
5050
}
5151

5252
}
@@ -57,8 +57,8 @@ open class InteractorExecuter {
5757
// Wrapper class for interactors.
5858
// This class is required as long as Swift does not support generic protocol types as variable types.
5959
// For instance:
60-
// let x = Interactor<RequestType> does not work
61-
// let x = InteractorWrapper<RequestType> does work
60+
// let x: Interactor<RequestType> does not work
61+
// let x: InteractorWrapper<RequestType> does work
6262

6363
private class InteractorWrapper<Request> {
6464

Sources/InteractorStatusInMemoryGateway.swift

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

33
class InteractorStatusInMemoryGateway: InteractorStatusGateway {
44

5-
fileprivate var running = false
5+
private var running = false
66

77
func isRunning() -> Bool {
8-
return self.running
8+
return running
99
}
1010

1111
func setRunning(_ running: Bool) {

Sources/LazyInteractor.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import Foundation
22

33
class LazyInteractor<InteractorType: Interactor>: Interactor {
44

5-
fileprivate(set) var lazyInstance: InteractorType?
6-
fileprivate let factory: ((Void) -> InteractorType)
5+
private(set) var lazyInstance: InteractorType?
6+
private let factory: ((Void) -> InteractorType)
77

8-
init(factory:@escaping ((Void) -> InteractorType)) {
8+
init(factory: @escaping ((Void) -> InteractorType)) {
99
self.factory = factory
1010
}
1111

@@ -15,13 +15,13 @@ class LazyInteractor<InteractorType: Interactor>: Interactor {
1515
}
1616

1717
let instance = factory()
18-
self.lazyInstance = instance
18+
lazyInstance = instance
1919

2020
return instance
2121
}
2222

2323
func execute(_ request: InteractorType.Request) {
24-
self.getInteractor().execute(request)
24+
getInteractor().execute(request)
2525
}
2626

2727
}
@@ -30,7 +30,7 @@ class LazyInteractor<InteractorType: Interactor>: Interactor {
3030
extension LazyInteractor: ErrorHandler {
3131

3232
func handleError(_ request: ErrorRequest, error: Error) {
33-
self.getInteractor().handleError(request, error: error)
33+
getInteractor().handleError(request, error: error)
3434
}
3535

3636
}

Tests/ACInteractorTests/ErrorHandlerExtensionTests.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ErrorHandlerExtensionTests: XCTestCase {
2828
interactor.handleError(request, error: error)
2929

3030
// Assert
31-
let errorResponse = onErrorResponse as? InteractorError
31+
let errorResponse = onErrorResponse as InteractorError?
3232
XCTAssert(errorResponse === error)
3333
}
3434

@@ -41,7 +41,7 @@ class ErrorHandlerExtensionTests: XCTestCase {
4141
interactor.handleError(request, error: nsError)
4242

4343
// Assert
44-
let errorResponse = onErrorResponse as? InteractorError
44+
let errorResponse = onErrorResponse as InteractorError?
4545
XCTAssert(errorResponse === nsError)
4646
}
4747

@@ -56,10 +56,4 @@ class ErrorHandlerExtensionTests: XCTestCase {
5656
}
5757
}
5858

59-
60-
// MARK: Test Error
61-
62-
class TestError: Error {
63-
}
64-
6559
}

Tests/ACInteractorTests/InteractorExecuterTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ class InteractorTests: XCTestCase {
104104
}
105105

106106
func execute(_ request: Request) {
107-
self.numberOfExceuteCalls += 1
108-
self.executedRequest = request
107+
numberOfExceuteCalls += 1
108+
executedRequest = request
109109
}
110110
}
111111

@@ -117,8 +117,8 @@ class InteractorTests: XCTestCase {
117117
}
118118

119119
func execute(_ request: Request) {
120-
self.numberOfExceuteCalls += 1
121-
self.executedRequest = request
120+
numberOfExceuteCalls += 1
121+
executedRequest = request
122122
}
123123
}
124124

Tests/ACInteractorTests/LazyInteractorTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ class LazyInteractorTests: XCTestCase {
9595
}
9696

9797
func execute(_ request: Request) {
98-
self.numberOfExceuteCalls += 1
99-
self.executedRequest = request
98+
numberOfExceuteCalls += 1
99+
executedRequest = request
100100
}
101101

102102
func handleError(_ request: ErrorRequest, error: Error) {
103-
self.handledErrorRequest = request
104-
self.handledError = error
103+
handledErrorRequest = request
104+
handledError = error
105105
}
106106
}
107107

0 commit comments

Comments
 (0)