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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -4
- data/README.md +49 -20
- data/app/models/rabarber/role.rb +153 -0
- data/app/models/rabarber/role_assignment.rb +10 -0
- data/lib/generators/rabarber/roles_generator.rb +6 -2
- data/lib/generators/rabarber/templates/create_rabarber_roles.rb.erb +4 -4
- data/lib/rabarber/configuration.rb +4 -4
- data/lib/rabarber/controllers/concerns/authorization.rb +5 -24
- data/lib/rabarber/core/cache.rb +19 -9
- data/lib/rabarber/core/roleable.rb +3 -5
- data/lib/rabarber/core/rule.rb +7 -13
- data/lib/rabarber/engine.rb +31 -0
- data/lib/rabarber/helpers/migration_helpers.rb +5 -16
- data/lib/rabarber/inputs/base.rb +5 -2
- data/lib/rabarber/inputs/boolean.rb +3 -1
- data/lib/rabarber/inputs/context.rb +5 -6
- data/lib/rabarber/inputs/contexts/authorizational.rb +2 -7
- data/lib/rabarber/inputs/dynamic_rule.rb +3 -1
- data/lib/rabarber/inputs/non_empty_string.rb +2 -0
- data/lib/rabarber/inputs/non_empty_symbol.rb +2 -0
- data/lib/rabarber/inputs/role.rb +2 -0
- data/lib/rabarber/inputs/roles.rb +3 -1
- data/lib/rabarber/models/concerns/roleable.rb +50 -58
- data/lib/rabarber/models/role_management.rb +8 -2
- data/lib/rabarber/version.rb +1 -1
- data/lib/rabarber.rb +7 -2
- data/rabarber.gemspec +2 -3
- metadata +13 -13
- data/lib/rabarber/models/role.rb +0 -124
- data/lib/rabarber/railtie.rb +0 -49
data/lib/rabarber/railtie.rb
DELETED
|
@@ -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
|