Module: SolidusSubscriptions::Interval

Included in:
LineItem, Subscription
Defined in:
app/models/solidus_subscriptions/interval.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
13
14
15
16
17
# File 'app/models/solidus_subscriptions/interval.rb', line 10

def self.included(base)
  base.enum interval_units: {
    day: 0,
    week: 1,
    month: 2,
    year: 3
  }
end

Instance Method Details

#intervalInteger

Calculates the number of seconds in the interval.

Returns:

  • (Integer)

    The number of seconds.



22
23
24
# File 'app/models/solidus_subscriptions/interval.rb', line 22

def interval
  ActiveSupport::Duration.new(interval_length, { interval_units.pluralize.to_sym => interval_length })
end