Class: ExternalId::Record

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/external_id/models/record.rb

Class Method Summary collapse

Class Method Details

.inherited(subclass) ⇒ Object

Call setup when the class is loaded



37
38
39
40
# File 'lib/external_id/models/record.rb', line 37

def self.inherited(subclass)
  super
  subclass.setup_enum! if subclass == ExternalId::Record
end

.providersObject

Define enum dynamically based on configuration



25
26
27
# File 'lib/external_id/models/record.rb', line 25

def self.providers
  @providers ||= ::ExternalId.configuration.providers
end

.setup_enum!Object

Set up enum if providers are configured



30
31
32
33
34
# File 'lib/external_id/models/record.rb', line 30

def self.setup_enum!
  return if providers.empty?

  enum :provider, providers, prefix: true
end