Class: Zillion::MeteredPlan
- Inherits:
-
TieredPlan
- Object
- Plan
- TieredPlan
- Zillion::MeteredPlan
- Defined in:
- lib/zillion/plan.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Plan
Instance Method Summary collapse
- #amounts_for(counts, custom_monthly_fee: nil, fallback: false) ⇒ Object
- #units_for(type, counts) ⇒ Object
Methods inherited from TieredPlan
#available_for?, #matching_tier_for
Methods inherited from Plan
#<=>, #available_for?, factory, #features, #has?, #initialize, #key, #limit_for, #limits, #monthly_fee_for, #name
Constructor Details
This class inherits a constructor from Zillion::Plan
Instance Method Details
#amounts_for(counts, custom_monthly_fee: nil, fallback: false) ⇒ Object
205 206 207 208 209 210 211 212 213 214 |
# File 'lib/zillion/plan.rb', line 205 def amounts_for(counts, custom_monthly_fee: nil, fallback: false) # raise "Tiered plans don't have fixed monthly fees! (Use FixedTieredPlan for that)" if custom_monthly_fee obj = {} matching_tiers_for(counts, fallback: fallback).map do |tier| units = units_for(tier.last, counts) obj[tier.last.to_sym] = units * tier[1] # tier[1] is monthly unit cost end obj end |
#units_for(type, counts) ⇒ Object
216 217 218 |
# File 'lib/zillion/plan.rb', line 216 def units_for(type, counts) counts[type] end |