Class: AdvancedBilling::RecurringScheme

Inherits:
Object
  • Object
show all
Defined in:
lib/advanced_billing/models/recurring_scheme.rb

Overview

Recurring Scheme.

Constant Summary collapse

RECURRING_SCHEME =
[
  # TODO: Write general description for DO_NOT_RECUR
  DO_NOT_RECUR = 'do_not_recur'.freeze,

  # TODO: Write general description for RECUR_INDEFINITELY
  RECUR_INDEFINITELY = 'recur_indefinitely'.freeze,

  # TODO: Write general description for RECUR_WITH_DURATION
  RECUR_WITH_DURATION = 'recur_with_duration'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = DO_NOT_RECUR) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/advanced_billing/models/recurring_scheme.rb', line 26

def self.from_value(value, default_value = DO_NOT_RECUR)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'do_not_recur' then DO_NOT_RECUR
  when 'recur_indefinitely' then RECUR_INDEFINITELY
  when 'recur_with_duration' then RECUR_WITH_DURATION
  else
    default_value
  end
end

.validate(value) ⇒ Object



20
21
22
23
24
# File 'lib/advanced_billing/models/recurring_scheme.rb', line 20

def self.validate(value)
  return false if value.nil?

  RECURRING_SCHEME.include?(value)
end