Class: AdvancedBilling::AutoInvite

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

Overview

Auto Invite.

Constant Summary collapse

AUTO_INVITE =
[
  # Do not send the invitation email.
  NO = 0,

  # Automatically send the invitation email.
  YES = 1
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = NO) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/advanced_billing/models/auto_invite.rb', line 23

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

  str = value.to_s.strip
  if str.match?(/\A\d+\z/)
    num = str.to_i
    return num if AUTO_INVITE.include?(num)

    return default_value
  end

  case str.downcase
  when 'no' then NO
  when 'yes' then YES
  else
    default_value
  end
end

.validate(value) ⇒ Object



17
18
19
20
21
# File 'lib/advanced_billing/models/auto_invite.rb', line 17

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

  AUTO_INVITE.include?(value)
end