Class: Munificent::DonatorBundleAssigner
- Inherits:
-
Object
- Object
- Munificent::DonatorBundleAssigner
- Defined in:
- app/services/munificent/donator_bundle_assigner.rb
Class Method Summary collapse
Instance Method Summary collapse
- #assign ⇒ Object
-
#initialize(donator:, bundle:, fund:) ⇒ DonatorBundleAssigner
constructor
A new instance of DonatorBundleAssigner.
Constructor Details
#initialize(donator:, bundle:, fund:) ⇒ DonatorBundleAssigner
Returns a new instance of DonatorBundleAssigner.
7 8 9 10 11 |
# File 'app/services/munificent/donator_bundle_assigner.rb', line 7 def initialize(donator:, bundle:, fund:) @donator = donator @bundle = bundle @fund = fund end |
Class Method Details
.assign ⇒ Object
3 4 5 |
# File 'app/services/munificent/donator_bundle_assigner.rb', line 3 def self.assign(...) new(...).assign end |
Instance Method Details
#assign ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/munificent/donator_bundle_assigner.rb', line 13 def assign return if fund.blank? || fund.zero? complete_bundles, partial_bundles = donator_bundles.partition(&:complete?) subtract_completed_bundle_value(complete_bundles) attempt_to_unlock_partial_bundles(partial_bundles) create_bundle_and_apportion_overpayment end |