bullet_train-roles 1.6.2 → 1.6.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d1f9f6406265c3dac5fe66d3afbcc1938fe73265358f137c88a0a7d766ebbd8
4
- data.tar.gz: b912092f5a2fff6f51ddd742af88bd4dfa1155c55c60c2d13369f5b8b7d7b36e
3
+ metadata.gz: 60ec09c4f08c24e3d3ec9c0a408d6c43395d9088ac37402e89bda662f5c97d7a
4
+ data.tar.gz: 9cde4b9cf4e9d678cc3d294e23d067bb9cb6602efa7d3d11ec08bde4d21d956e
5
5
  SHA512:
6
- metadata.gz: 6099e6c850cd5830a5ccb1430e048d0698fbc91606dc96453d640141d07074200dfdddcebe805782211d0eb71194665a57e9727391157d299d584d09e0ab9e8a
7
- data.tar.gz: 9598cdcb844fa569cf78eb236bdb7e19c5792e7eeb9e4aec6282dfa1b72027e9adb2ee4092b798e6f3014d13e6a5e5594a9aff9d2f836e4af7a82190f8aa6fe4
6
+ metadata.gz: f7a33a5bc6b601f07d06f836a2dc529e69eec5dd6a45e9da247ed2ba4c97d4ec25af4e3f59cc91546310b69c8339308ad8cf542cc050e83350cb2f88d30bada9
7
+ data.tar.gz: c6cc4b869a353bb0855d6b30223a315fd433701b94f7ef7dccc107a40263052daccda5097459c2c730921c5d83ba8a9240b6bf4513824b08716d316c7ba7ef70
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- bullet_train-roles (1.6.2)
12
+ bullet_train-roles (1.6.4)
13
13
  active_hash
14
14
  activesupport
15
15
  cancancan
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Roles
4
- VERSION = "1.6.2"
4
+ VERSION = "1.6.4"
5
5
  end
@@ -47,7 +47,7 @@ module BulletTrain
47
47
  end
48
48
 
49
49
  def db_adapter
50
- allowed_adapter_types = %w[mysql mysql2 sqlite postgresql]
50
+ allowed_adapter_types = %w[mysql mysql2 sqlite postgresql trilogy]
51
51
 
52
52
  adapter_name = ActiveRecord::Base.connection.adapter_name.downcase
53
53
 
data/lib/roles/support.rb CHANGED
@@ -40,7 +40,7 @@ module Roles
40
40
  # For example, if you do with_roles(editor) it will return admin users if the admin role includes the editor role
41
41
  def self.with_roles(roles)
42
42
  # Mysql and postgres have different syntax for searching json or jsonb columns so we need different queries depending on the database
43
- ActiveRecord::Base.connection.adapter_name.downcase.include?("mysql") ? with_roles_mysql(roles) : with_roles_postgres(roles)
43
+ mysql? ? with_roles_mysql(roles) : with_roles_postgres(roles)
44
44
  end
45
45
 
46
46
  def self.with_roles_mysql(roles)
@@ -56,6 +56,10 @@ module Roles
56
56
  where("#{table_name}.role_ids ?| array[:keys]", keys: roles.map(&:key_plus_included_by_keys).flatten.uniq.map(&:to_s))
57
57
  end
58
58
 
59
+ def self.mysql?
60
+ ["mysql", "trilogy"].any? { |adapter| ActiveRecord::Base.connection.adapter_name.downcase.include?(adapter) }
61
+ end
62
+
59
63
  def validate_roles
60
64
  self.role_ids = role_ids&.select(&:present?) || []
61
65
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-roles
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Prabin Poudel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-10-10 00:00:00.000000000 Z
12
+ date: 2023-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: byebug