Class: Munificent::ExistingDonatorFinder
- Inherits:
-
Object
- Object
- Munificent::ExistingDonatorFinder
- Defined in:
- app/services/munificent/existing_donator_finder.rb
Class Method Summary collapse
Instance Method Summary collapse
- #find ⇒ Object
-
#initialize(current_donator:, email_address:) ⇒ ExistingDonatorFinder
constructor
A new instance of ExistingDonatorFinder.
Constructor Details
#initialize(current_donator:, email_address:) ⇒ ExistingDonatorFinder
Returns a new instance of ExistingDonatorFinder.
7 8 9 10 11 12 13 14 |
# File 'app/services/munificent/existing_donator_finder.rb', line 7 def initialize(current_donator:, email_address:) if current_donator.blank? && email_address.blank? raise ArgumentError, "You must provide either an email address or a current donator" end @current_donator = current_donator @email_address = email_address end |
Class Method Details
.find ⇒ Object
3 4 5 |
# File 'app/services/munificent/existing_donator_finder.rb', line 3 def self.find(...) new(...).find end |
Instance Method Details
#find ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/munificent/existing_donator_finder.rb', line 16 def find if email_address_not_provided? no_choice_but_to_use_current_donator elsif current_donator_not_provided? prefer_confirmed_donator_but_accept_unconfirmed_donator elsif established_current_donator? always_use_established_current_donator else prefer_confirmed_donator_but_accept_new_donator end end |