Module: CreditCardValidations

Extended by:
ActiveSupport::Autoload
Defined in:
lib/credit_card_validations/luhn.rb,
lib/credit_card_validations.rb,
lib/credit_card_validations/mmi.rb,
lib/credit_card_validations/error.rb,
lib/credit_card_validations/factory.rb,
lib/credit_card_validations/version.rb,
lib/credit_card_validations/detector.rb,
lib/credit_card_validations/configuration.rb

Overview

CreditCardValidations Detector

class provides credit card number validations

Defined Under Namespace

Modules: Mmi Classes: Configuration, Detector, Error, Factory, Luhn

Constant Summary collapse

VERSION =
'7.0.0'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



18
19
20
# File 'lib/credit_card_validations.rb', line 18

def configuration
  @configuration
end

Class Method Details

.add_brand(key, rules, options = {}) ⇒ Object



33
34
35
# File 'lib/credit_card_validations.rb', line 33

def self.add_brand(key, rules, options = {})
  Detector.add_brand(key, rules, options)
end

.configurationObject



20
21
22
# File 'lib/credit_card_validations.rb', line 20

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



28
29
30
31
# File 'lib/credit_card_validations.rb', line 28

def self.configure
  yield(configuration)
  reload!
end

.dataObject



41
42
43
# File 'lib/credit_card_validations.rb', line 41

def self.data
  YAML.load_file(source) || {}
end

.reload!Object



45
46
47
48
49
50
# File 'lib/credit_card_validations.rb', line 45

def self.reload!
  Detector.brands = {}
  data.each do |key, data|
    add_brand(key, data.fetch(:rules), data.fetch(:options, {}))
  end
end

.resetObject



24
25
26
# File 'lib/credit_card_validations.rb', line 24

def self.reset
  @configuration = Configuration.new
end

.sourceObject



37
38
39
# File 'lib/credit_card_validations.rb', line 37

def self.source
  configuration.source || File.join(File.join(File.dirname(__FILE__)), 'data', 'brands.yaml')
end