veri 2.0.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/veri/railtie.rb DELETED
@@ -1,44 +0,0 @@
1
- require "rails/railtie"
2
-
3
- module Veri
4
- class Railtie < Rails::Railtie
5
- def self.server_running?
6
- !!defined?(Rails::Server)
7
- end
8
-
9
- def self.table_exists?
10
- ActiveRecord::Base.connection.data_source_exists?("veri_sessions")
11
- rescue ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished
12
- false
13
- end
14
-
15
- initializer "veri.to_prepare" do |app|
16
- app.config.to_prepare do
17
- if Veri::Railtie.server_running? && Veri::Railtie.table_exists?
18
- Veri::Session.where.not(tenant_id: nil).distinct.pluck(:tenant_type).each do |tenant_class|
19
- tenant_class.constantize
20
- rescue NameError => e
21
- raise Veri::Error, "Tenant not found: class `#{e.name}` may have been renamed or deleted"
22
- end
23
- end
24
-
25
- begin
26
- user_model = Veri::Configuration.user_model
27
- user_model.include Veri::Authenticatable unless user_model < Veri::Authenticatable
28
- rescue Veri::ConfigurationError
29
- raise if Veri::Railtie.server_running?
30
- end
31
-
32
- Veri::Session.belongs_to :authenticatable, class_name: Veri::Configuration.user_model_name
33
- Veri::Session.belongs_to :original_authenticatable, class_name: Veri::Configuration.user_model_name,
34
- optional: true
35
- end
36
- end
37
-
38
- initializer "veri.extend_migration_helpers" do
39
- ActiveSupport.on_load :active_record do
40
- ActiveRecord::Migration.include Veri::MigrationHelpers
41
- end
42
- end
43
- end
44
- end