-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathauthorization_request_condition_facade.rb
47 lines (41 loc) · 1.27 KB
/
authorization_request_condition_facade.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
class AuthorizationRequestConditionFacade < SimpleDelegator
def not_editor_and_demandeur_different_to_other_contacts?
not_editor_authorization_request &&
(
same_contact_everywhere? ||
(demandeur.email != contact_technique&.email &&
contact_technique&.email == contact_metier&.email)
)
end
def not_editor_and_all_contacts_have_the_same_email?
not_editor_authorization_request &&
[
demandeur.email,
contact_technique&.email,
contact_metier&.email
].uniq.count == 1
end
def not_editor_and_user_is_contact_technique_and_not_contact_metier?
not_editor_authorization_request &&
demandeur.email == contact_technique&.email &&
demandeur.email != contact_metier&.email
end
def not_editor_and_user_is_contact_metier_and_not_contact_technique?
not_editor_authorization_request &&
demandeur.email == contact_metier&.email &&
demandeur.email != contact_technique&.email
end
def editor_authorization_request
demarche == 'editeurs'
end
def not_editor_authorization_request
!editor_authorization_request
end
def same_contact_everywhere?
[
demandeur.email,
contact_technique&.email,
contact_metier&.email
].uniq.count == 3
end
end