rabarber 6.0.2 → 6.1.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.
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/railtie"
4
-
5
- module Rabarber
6
- class Railtie < Rails::Railtie
7
- def self.server_running?
8
- !!defined?(Rails::Server)
9
- end
10
-
11
- def self.table_exists?
12
- ActiveRecord::Base.connection.data_source_exists?("rabarber_roles")
13
- rescue ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished
14
- false
15
- end
16
-
17
- initializer "rabarber.to_prepare" do |app|
18
- app.config.to_prepare do
19
- if Rabarber::Railtie.server_running? && Rabarber::Railtie.table_exists?
20
- Rabarber::Role.where.not(context_type: nil).distinct.pluck(:context_type).each do |context_class|
21
- context_class.constantize
22
- rescue NameError => e
23
- raise Rabarber::Error, "Context not found: class `#{e.name}` may have been renamed or deleted"
24
- end
25
- end
26
-
27
- Rabarber::Core::Permissions.reset! unless app.config.eager_load
28
-
29
- begin
30
- user_model = Rabarber::Configuration.user_model
31
- user_model.include Rabarber::Roleable unless user_model < Rabarber::Roleable
32
- rescue Rabarber::ConfigurationError
33
- raise if Rabarber::Railtie.server_running?
34
- end
35
-
36
- Rabarber::Role.send(:remove_const, :HABTM_Roleables) if Rabarber::Role.const_defined?(:HABTM_Roleables, false)
37
- Rabarber::Role.has_and_belongs_to_many :roleables, class_name: Rabarber::Configuration.user_model_name,
38
- association_foreign_key: "roleable_id",
39
- join_table: "rabarber_roles_roleables"
40
- end
41
- end
42
-
43
- initializer "rabarber.extend_migration_helpers" do
44
- ActiveSupport.on_load :active_record do
45
- ActiveRecord::Migration.include Rabarber::MigrationHelpers
46
- end
47
- end
48
- end
49
- end