class Sorare::Rewards::Allocations::ComputeForRarity

ComputeForRarity computes the reward allocations for a rarity in a league

Public Instance Methods

allocations() click to toggle source
# File lib/sorare/rewards/interactors/allocations/compute_for_rarity.rb, line 21
def allocations
  return [] unless supply

  supply.each_with_index.map do |tier_supply, tier|
    ComputeForQuality.call!(
      **context.to_h,
      supply: tier_supply,
      config: tier_config(tier)
    ).quality_allocations
  end
end
call() click to toggle source
# File lib/sorare/rewards/interactors/allocations/compute_for_rarity.rb, line 15
def call
  context.fail!(error: 'Invalid config') unless config

  context.rarity_allocations = allocations
end
tier_config(tier) click to toggle source
# File lib/sorare/rewards/interactors/allocations/compute_for_rarity.rb, line 33
def tier_config(tier)
  config[Sorare::Rewards.configuration.transform_tier.call(tier)]
end