class Sorare::Rewards::Allocations::ComputeForLeague
ComputeForLeague
computes the reward allocations for a league given a supply and configuration
Public Instance Methods
allocate_and_format!()
click to toggle source
# File lib/sorare/rewards/interactors/allocations/compute_for_league.rb, line 19 def allocate_and_format! each_rarity_allocation do |rarity| (allocations[rarity].first || {}).keys.index_with do |division| allocations[rarity].each_with_index.map do |qualified_allocations, tier| [Sorare::Rewards.configuration.transform_tier.call(tier), qualified_allocations[division]] end.to_h end end end
allocations()
click to toggle source
# File lib/sorare/rewards/interactors/allocations/compute_for_league.rb, line 33 def allocations @allocations ||= (config || {}).keys.index_with do |rarity| ComputeForRarity.call!(**context.to_h, supply: supply[rarity], config: config[rarity]).rarity_allocations end end
call()
click to toggle source
# File lib/sorare/rewards/interactors/allocations/compute_for_league.rb, line 15 def call context.league_allocations = allocate_and_format! end
each_rarity_allocation(&block)
click to toggle source
# File lib/sorare/rewards/interactors/allocations/compute_for_league.rb, line 29 def each_rarity_allocation(&block) allocations.keys.index_with(&block) end