-
Notifications
You must be signed in to change notification settings - Fork 9
/
repository_interface.rb
102 lines (85 loc) · 2.43 KB
/
repository_interface.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# frozen_string_literal: true
module User::Adapters::RepositoryInterface
include Solid::Adapters::Interface
module Methods
def find_by(**attributes)
super.tap do
_1 => (
Solid::Failure(:user_not_found, {}) |
Solid::Success(:user_found, {user: User::Entity})
)
end
end
def exists?(**attributes)
super.tap { _1 => true | false }
end
def create!(uuid:, email:, password:, password_confirmation:)
uuid => String
email => String
password => String
password_confirmation => String
super.tap do
_1 => (
Solid::Failure(:invalid_user, {user: User::Entity}) |
Solid::Success(:user_created, {user: User::Entity})
)
end
end
def destroy!(user:)
user => User::Entity
super.tap { _1 => Solid::Success(:user_deleted, {user: User::Entity}) }
end
def fetch_by_token(value)
value => String
super.tap do
_1 => (
Solid::Failure(:invalid_token, {}) |
Solid::Success(:user_found, {user: User::Entity})
)
end
end
def find_by_email_and_password(email:, password:)
email => String
password => String
super.tap do
_1 => (
Solid::Failure(:invalid_email_or_password, {}) |
Solid::Success(:user_found, {user: User::Entity})
)
end
end
def find_by_reset_password(token:)
token => String
super.tap do
_1 => (
Solid::Failure(:invalid_or_expired_token, {}) |
Solid::Success(:user_found, {user: User::Entity})
)
end
end
def reset_password(token:, password:, password_confirmation:)
token => String
password => String
password_confirmation => String
super.tap do
_1 => (
Solid::Failure(:invalid_user, {user: User::Entity}) |
Solid::Failure(:invalid_or_expired_token, {}) |
Solid::Success(:password_updated, {user: User::Entity})
)
end
end
def update_password(user:, password:, password_confirmation:, current_password:)
user => User::Entity
password => String
password_confirmation => String
current_password => String
super.tap do
_1 => (
Solid::Failure(:invalid_password, {user: User::Entity}) |
Solid::Success(:password_updated, {user: User::Entity})
)
end
end
end
end