Class: UsageCredits::CreditSubscriptionPlan::CreditGiver
- Inherits:
-
Object
- Object
- UsageCredits::CreditSubscriptionPlan::CreditGiver
- Defined in:
- lib/usage_credits/models/credit_subscription_plan.rb
Overview
CreditGiver is a helper class that enables the DSL within ‘subscription_plan` blocks to define credit amounts.
This is what allows us to write:
gives 10_000.credits.every(:month)
Instead of:
set_credits(10_000)
set_period(:month)
Instance Method Summary collapse
- #every(period) ⇒ Object
-
#initialize(plan) ⇒ CreditGiver
constructor
A new instance of CreditGiver.
Constructor Details
#initialize(plan) ⇒ CreditGiver
Returns a new instance of CreditGiver.
193 194 195 |
# File 'lib/usage_credits/models/credit_subscription_plan.rb', line 193 def initialize(plan) @plan = plan end |
Instance Method Details
#every(period) ⇒ Object
197 198 199 200 |
# File 'lib/usage_credits/models/credit_subscription_plan.rb', line 197 def every(period) @plan.fulfillment_period = UsageCredits::PeriodParser.normalize_period(period) @plan end |