-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
6 another way to create interface (#7)
* fix * fix test * 0.2.4 * fix test yaml
- Loading branch information
1 parent
3b64362
commit 3e15837
Showing
23 changed files
with
355 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ./repository | ||
import ./usecase | ||
|
||
proc main() = | ||
let repo = Repository.new() | ||
let usecase = Usecase.new(repo) | ||
usecase.exec() | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import ./repository_interface | ||
|
||
type Repository* = object of IRepository | ||
|
||
proc execImpl(self:IRepository, msg:string):string = | ||
return "Repository " & msg | ||
|
||
proc new*(_:type Repository):Repository = | ||
return Repository( | ||
exec:execImpl | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type IRepository* = object of RootObj | ||
exec:proc(self:IRepository, msg:string):string | ||
|
||
proc exec*(self:IRepository, msg:string):string = self.exec(self, msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import ./repository_interface | ||
|
||
type Usecase* = object | ||
repo:IRepository | ||
|
||
proc new*(_:type Usecase, repo:IRepository):Usecase = | ||
return Usecase( | ||
repo:repo | ||
) | ||
|
||
proc exec*(self:Usecase) = | ||
echo self.repo.exec("hoge") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ./repository | ||
import ./usecase | ||
|
||
proc main() = | ||
let repo = Repository.new() | ||
let usecase = Usecase.new(repo) | ||
usecase.exec() | ||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ./repository_interface | ||
|
||
type Repository* = object of IRepository | ||
|
||
proc new*(_:type Repository):Repository = | ||
return Repository() | ||
|
||
method exec*(self:Repository, msg:string):string = | ||
return "Repository " & msg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
type IRepository* = object of RootObj | ||
|
||
method exec*(self:IRepository, msg:string):string {.base.} = raise newException(Exception, "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import ./repository_interface | ||
|
||
type Usecase* = object | ||
repo:IRepository | ||
|
||
proc new*(_:type Usecase, repo:IRepository):Usecase = | ||
return Usecase( | ||
repo:repo | ||
) | ||
|
||
proc exec*(self:Usecase) = | ||
echo self.repo.exec("hoge") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.