Class: Zillion::TieredPlan
- Inherits:
-
Plan
- Object
- Plan
- Zillion::TieredPlan
show all
- Defined in:
- lib/zillion/plan.rb
Constant Summary
Constants inherited
from Plan
Plan::TYPES
Instance Method Summary
collapse
Methods inherited from Plan
#<=>, 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
128
129
130
131
132
133
134
|
# File 'lib/zillion/plan.rb', line 128
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
tier = matching_tier_for(counts)
obj = {}
obj[tier.last.to_sym] = tier[1] obj
end
|
#available_for?(counts) ⇒ Boolean
145
146
147
148
|
# File 'lib/zillion/plan.rb', line 145
def available_for?(counts)
super
matching_tiers_for(counts).any?
end
|
#matching_tier_for(counts) ⇒ Object
136
137
138
139
140
141
142
143
|
# File 'lib/zillion/plan.rb', line 136
def matching_tier_for(counts)
if tiers = matching_tiers_for(counts) and tiers.any?
tiers.sort { |a, b| a[1] <=> b[1] }.last
else
raise TierNotFoundError.new("No matching tiers found for #{counts.inspect} in #{name} plan.")
end
end
|