edge_rider 2.2.0 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e76fe31acbaa313ea4b8d6eec7a26809dd3a340cd6b9d8cda55305f9c8f71157
4
- data.tar.gz: ca5884575995ddb539a74262d682648e44325e454e8fce1e0f0da33d487969e0
3
+ metadata.gz: 32bfec9bfa5c200e32346b737cab2a2ca8022a7970592b545ea441d18fc7cb1e
4
+ data.tar.gz: 27a7901e4a45da9e8c82672b4c94157a811308a85fbef9bda063c2c8854bbf3a
5
5
  SHA512:
6
- metadata.gz: 3fca12b801fd31fb76480118fb57e42ec7db53de75888e0f6714fc523f897f64cc0f44cdfbc44ebb024b12cd9ea783c68a45c72756bdfa3416838973bce9f7e5
7
- data.tar.gz: b468254fface8669ae9bb26b1a71ebd80ba70c4c10f4a857ddd568d791582e002e5aa3ef8542e89f72689932c95ce111c31ac39608843f02dd29c23782666558
6
+ metadata.gz: 56a14c1c14b1385eeacbea770151e82237fda1b0c80e3b774127f47dfc97ebda0886e455a60958784e6d65c07b7da52902b4f88311b376c2b7ea8b6b490e1428
7
+ data.tar.gz: bbda66b48e74e0515b38b1959d1836a77aced98bdb90778d215698a3886c88828edcc7ab0463ce40ffbcfd757addf534fb3690508dfad155aac51557003a9208
@@ -49,7 +49,7 @@ jobs:
49
49
  - name: Run tests
50
50
  run: bundle exec rspec
51
51
  test_pg:
52
- runs-on: ubuntu-20.04
52
+ runs-on: ubuntu-22.04
53
53
  services:
54
54
  postgres:
55
55
  image: postgres
data/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
10
10
  ### Compatible changes
11
11
 
12
12
 
13
+ ## 2.3.1 - 2024-10-18
14
+
15
+ ### Compatible changes
16
+
17
+ - Follow recommended way to extend Railties
18
+
19
+ ## 2.3.0 - 2023-05-26
20
+
21
+ ### Compatible changes
22
+
23
+ - `collect_ids` is now capable of parsing "string arrays" like `['1', '2', '3']`. This can be handy when handling params with ID arrays.
24
+
13
25
  ## 2.2.0 - 2023-03-01
14
26
 
15
27
  ### Compatible changes
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- edge_rider (2.2.0)
4
+ edge_rider (2.3.1)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
data/Gemfile.4.2.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- edge_rider (2.2.0)
4
+ edge_rider (2.3.1)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- edge_rider (2.2.0)
4
+ edge_rider (2.3.1)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -76,4 +76,4 @@ DEPENDENCIES
76
76
  rspec
77
77
 
78
78
  BUNDLED WITH
79
- 2.3.4
79
+ 2.3.26
data/Gemfile.5.2.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- edge_rider (2.2.0)
4
+ edge_rider (2.3.1)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -76,4 +76,4 @@ DEPENDENCIES
76
76
  rspec
77
77
 
78
78
  BUNDLED WITH
79
- 2.3.4
79
+ 2.3.26
data/Gemfile.6.1.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- edge_rider (2.2.0)
4
+ edge_rider (2.3.1)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
data/Gemfile.7.0.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- edge_rider (2.2.0)
4
+ edge_rider (2.3.1)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -75,4 +75,4 @@ DEPENDENCIES
75
75
  rspec
76
76
 
77
77
  BUNDLED WITH
78
- 2.3.4
78
+ 2.3.13
@@ -16,7 +16,9 @@ module EdgeRider
16
16
  scope.pluck(qualified_column_name)
17
17
  end
18
18
 
19
- ActiveRecord::Base.extend(self)
20
-
21
19
  end
22
20
  end
21
+
22
+ ActiveSupport.on_load :active_record do
23
+ extend(EdgeRider::CollectColumn)
24
+ end
@@ -8,9 +8,18 @@ module EdgeRider
8
8
  def collect_ids
9
9
  collect do |obj|
10
10
  case obj
11
- when Integer then obj
12
- when ActiveRecord::Base then obj.id
13
- else raise Uncollectable, "Cannot collect an id from #{obj.inspect}"
11
+ when Integer
12
+ obj
13
+ when ActiveRecord::Base
14
+ obj.id
15
+ when String
16
+ if obj.match(/\A\d+\z/)
17
+ obj.to_i
18
+ else
19
+ raise Uncollectable, "Cannot collect an id from #{obj.inspect}"
20
+ end
21
+ else
22
+ raise Uncollectable, "Cannot collect an id from #{obj.inspect}"
14
23
  end
15
24
  end
16
25
  end
@@ -27,8 +36,6 @@ module EdgeRider
27
36
 
28
37
  end
29
38
 
30
- ::ActiveRecord::Base.send(:include, ActiveRecordValue)
31
-
32
39
  module ActiveRecordScope
33
40
 
34
41
  def collect_ids
@@ -37,10 +44,6 @@ module EdgeRider
37
44
 
38
45
  end
39
46
 
40
- ::ActiveRecord::Base.send(:extend, ActiveRecordScope)
41
- ::ActiveRecord::Associations::HasManyAssociation.send(:include, ActiveRecordScope)
42
- ::ActiveRecord::Associations::HasManyThroughAssociation.send(:include, ActiveRecordScope)
43
-
44
47
  module Integer
45
48
 
46
49
  def collect_ids
@@ -53,3 +56,10 @@ module EdgeRider
53
56
 
54
57
  end
55
58
  end
59
+
60
+ ActiveSupport.on_load :active_record do
61
+ extend(EdgeRider::CollectIds::ActiveRecordScope)
62
+ include(EdgeRider::CollectIds::ActiveRecordValue)
63
+ ActiveRecord::Associations::HasManyAssociation.send(:include, EdgeRider::CollectIds::ActiveRecordScope)
64
+ ActiveRecord::Associations::HasManyThroughAssociation.send(:include, EdgeRider::CollectIds::ActiveRecordScope)
65
+ end
@@ -9,7 +9,9 @@ module EdgeRider
9
9
  scope
10
10
  end
11
11
 
12
- ActiveRecord::Base.extend(self)
13
-
14
12
  end
15
13
  end
14
+
15
+ ActiveSupport.on_load :active_record do
16
+ extend(EdgeRider::OriginClass)
17
+ end
@@ -20,8 +20,10 @@ module EdgeRider
20
20
  preloader.new(records: records, associations: associations, **options).call
21
21
  end
22
22
  end
23
-
24
- ActiveRecord::Base.send(:extend, self)
25
- ActiveRecord::Base.send(:include, PreloadAssociationsInstanceMethod)
26
23
  end
27
24
  end
25
+
26
+ ActiveSupport.on_load :active_record do
27
+ extend(EdgeRider::PreloadAssociations)
28
+ include(EdgeRider::PreloadAssociations::PreloadAssociationsInstanceMethod)
29
+ end
@@ -1,30 +1,32 @@
1
1
  module EdgeRider
2
2
  module Scoped
3
-
3
+
4
4
  VALID_FIND_OPTIONS = [ :conditions, :include, :joins, :limit, :offset,
5
5
  :order, :select, :readonly, :group, :having, :from, :lock ]
6
6
 
7
7
  def scoped(options = nil)
8
8
  options ||= {}
9
9
  relation = all
10
-
10
+
11
11
  options.assert_valid_keys(VALID_FIND_OPTIONS)
12
12
  finders = options.dup
13
13
  finders.delete_if { |key, value| value.nil? && key != :limit }
14
-
14
+
15
15
  ((VALID_FIND_OPTIONS - [:conditions, :include]) & finders.keys).each do |finder|
16
16
  relation = relation.send(finder, finders[finder])
17
17
  end
18
-
18
+
19
19
  relation = relation.where(finders[:conditions]) if options.has_key?(:conditions)
20
20
  relation = relation.includes(finders[:include]) if options.has_key?(:include)
21
-
21
+
22
22
  relation
23
23
  end
24
24
 
25
- if ActiveRecord::VERSION::MAJOR >= 4
26
- ActiveRecord::Base.extend(self)
27
- end
25
+ end
26
+ end
28
27
 
28
+ ActiveSupport.on_load :active_record do
29
+ if ActiveRecord::VERSION::MAJOR >= 4
30
+ extend(EdgeRider::Scoped)
29
31
  end
30
32
  end
@@ -5,8 +5,9 @@ module EdgeRider
5
5
  ids = collect_ids
6
6
  EdgeRider::Util.exclusive_query(self, id: ids)
7
7
  end
8
-
9
- ActiveRecord::Base.send(:extend, self)
10
-
11
8
  end
12
9
  end
10
+
11
+ ActiveSupport.on_load :active_record do
12
+ extend(EdgeRider::ToIdQuery)
13
+ end
@@ -16,7 +16,7 @@ module EdgeRider
16
16
  # In Rails 4, conditions on a scope are expressed as a lambda parameter
17
17
  # that is called `scope`.
18
18
  raise NotImplementedError if reflection.options[:conditions] or (reflection.respond_to?(:scope) && reflection.scope)
19
-
19
+
20
20
  if reflection.macro == :belongs_to # belongs_to
21
21
  ids = scope.collect_column(foreign_key, distinct: true)
22
22
  scope = EdgeRider::Util.exclusive_query(reflection.klass, id: ids)
@@ -40,7 +40,9 @@ module EdgeRider
40
40
 
41
41
  end
42
42
 
43
- ActiveRecord::Base.extend(self)
44
-
45
43
  end
46
44
  end
45
+
46
+ ActiveSupport.on_load :active_record do
47
+ extend(EdgeRider::TraverseAssociation)
48
+ end
@@ -1,3 +1,3 @@
1
1
  module EdgeRider
2
- VERSION = '2.2.0'
2
+ VERSION = '2.3.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edge_rider
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-01 00:00:00.000000000 Z
11
+ date: 2024-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord