octoball 0.1.8 → 0.1.9

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: 825cfa3ec263110a928737f918d0576459a50aa67b1f1553ab194248e0c0d41c
4
- data.tar.gz: c20b43133b0afd7c324b4cd57a54204d7c716f85acb7aa55a950be80e2bcec02
3
+ metadata.gz: edf38b936ff98ea6c1ca5ceef00f67c33c0cf79f66cd4541999d5071b4364629
4
+ data.tar.gz: b6b385dbc74bdb498f94b6d61bf529cc9d89f2d2ac21b4e411db61504ae6c8b2
5
5
  SHA512:
6
- metadata.gz: 0002bc390d5982cb4a968ecdd91d12234a4d495553e906c0765efc09c29111b72fd136b15bd8fbd8a3b30b8b0f6d25fb9e6b41c5138ee777e791773a5117fcc6
7
- data.tar.gz: 37efcbe5015be915ae7263a03f6da3443f03b6de711389ec59c76ada5fb0ea3a786c072c358a9f27573df1741ae978ef723930bb8ea4503fa80563669b13880e
6
+ metadata.gz: a6bea44ca7cfb357ad35f6090f0efed3434da75924895cbab125268b4900bd7e5d7c00414c8cb256b6ecddbd6f6e42cc2bb7a06443942e506a9793e6490c2f0c
7
+ data.tar.gz: ab20e4a63e2744a85c75f9b9625677cd37bfd216e66f33b23de98ae8fc9a89cfd862264e5ba3ec4393e77a89e0c52cf3d756c60b1230ca15ea5d80504b469d59
@@ -5,7 +5,7 @@ jobs:
5
5
  runs-on: ubuntu-latest
6
6
  services:
7
7
  mysql:
8
- image: mysql:5
8
+ image: mysql:8
9
9
  ports:
10
10
  - 3306:3306
11
11
  env:
@@ -17,7 +17,7 @@ jobs:
17
17
  strategy:
18
18
  fail-fast: true
19
19
  matrix:
20
- ruby: ["3.2", "3.3", "3.4"]
20
+ ruby: ["3.2", "3.3", "3.4", "4.0"]
21
21
  rails: ["7.2", "8.0", "8.1"]
22
22
  env:
23
23
  BUNDLE_GEMFILE: .github/gemfiles/rails_${{ matrix.rails }}.gemfile
@@ -25,7 +25,7 @@ jobs:
25
25
  RAILS_ENV: test
26
26
  steps:
27
27
  - name: Checkout
28
- uses: actions/checkout@v4
28
+ uses: actions/checkout@v6
29
29
  - name: Setup ruby
30
30
  uses: ruby/setup-ruby@v1
31
31
  with:
@@ -15,7 +15,7 @@ class Octoball
15
15
  [:writer, :ids_reader, :ids_writer, :create, :create!,
16
16
  :build, :include?, :load_target, :reload, :size, :select].each do |method|
17
17
  class_eval <<-"END", __FILE__, __LINE__ + 1
18
- def #{method}(*args, &block)
18
+ def #{method}(...)
19
19
  shard = owner.current_shard
20
20
  return super if !shard || shard == ActiveRecord::Base.current_shard
21
21
  ret = nil
@@ -27,7 +27,6 @@ class Octoball
27
27
  end
28
28
  ret
29
29
  end
30
- ruby2_keywords(:#{method}) if respond_to?(:ruby2_keywords, true)
31
30
  END
32
31
  end
33
32
  end
@@ -51,13 +50,12 @@ class Octoball
51
50
  :destroy, :destroy_all, :empty?, :find, :first, :include?, :last, :length,
52
51
  :many?, :pluck, :replace, :select, :size, :sum, :to_a, :uniq].each do |method|
53
52
  class_eval <<-"END", __FILE__, __LINE__ + 1
54
- def #{method}(*args, &block)
53
+ def #{method}(...)
55
54
  return super if !@association.owner.current_shard || @association.owner.current_shard == ActiveRecord::Base.current_shard
56
55
  ActiveRecord::Base.connected_to(shard: @association.owner.current_shard, role: Octoball.current_role) do
57
56
  super
58
57
  end
59
58
  end
60
- ruby2_keywords(:#{method}) if respond_to?(:ruby2_keywords, true)
61
59
  END
62
60
  end
63
61
  end
@@ -65,13 +63,12 @@ class Octoball
65
63
  module ShardedSingularAssociation
66
64
  [:reload, :writer, :create, :create!, :build].each do |method|
67
65
  class_eval <<-"END", __FILE__, __LINE__ + 1
68
- def #{method}(*args, &block)
66
+ def #{method}(...)
69
67
  return super if !owner.current_shard || owner.current_shard == ActiveRecord::Base.current_shard
70
68
  ActiveRecord::Base.connected_to(shard: owner.current_shard, role: Octoball.current_role) do
71
69
  super
72
70
  end
73
71
  end
74
- ruby2_keywords(:#{method}) if respond_to?(:ruby2_keywords, true)
75
72
  END
76
73
  end
77
74
  end
@@ -17,7 +17,7 @@ class Octoball
17
17
  module ClassMethods
18
18
  private
19
19
 
20
- def instantiate_instance_of(klass, attributes, column_types = {}, &block)
20
+ def instantiate_instance_of(...)
21
21
  result = super
22
22
  result.instance_variable_set(:@current_shard, current_shard)
23
23
  result
@@ -11,9 +11,9 @@ class Octoball
11
11
 
12
12
  private
13
13
 
14
- def debug(progname = nil, &block)
14
+ def debug(progname = nil, &)
15
15
  conn = current_shard ? color("[Shard: #{current_shard}]", ActiveSupport::LogSubscriber::GREEN, bold: true) : ''
16
- super(conn + progname.to_s, &block)
16
+ super(conn + progname.to_s, &)
17
17
  end
18
18
  end
19
19
  end
@@ -7,13 +7,12 @@ class Octoball
7
7
  [:update_columns, :increment!, :reload, :_delete_row, :_touch_row, :_update_row, :_create_record,
8
8
  :transaction, :with_transaction_returning_status].each do |method|
9
9
  class_eval <<-"END", __FILE__, __LINE__ + 1
10
- def #{method}(*args, &block)
10
+ def #{method}(...)
11
11
  return super if !current_shard || current_shard == ActiveRecord::Base.current_shard
12
12
  ActiveRecord::Base.connected_to(shard: current_shard, role: Octoball.current_role) do
13
13
  super
14
14
  end
15
15
  end
16
- ruby2_keywords(:#{method}) if respond_to?(:ruby2_keywords, true)
17
16
  END
18
17
  end
19
18
 
@@ -33,26 +33,25 @@ class Octoball
33
33
  end + [:each, :map, :index_by]
34
34
  ENUM_WITH_BLOCK_METHODS = [:find, :select, :none?, :any?, :one?, :many?, :sum]
35
35
 
36
- def method_missing(method, *args, &block)
36
+ def method_missing(method, ...)
37
37
  # raise NoMethodError unless the method is defined in @rel
38
- return @rel.public_send(method, *args, &block) unless @rel.respond_to?(method)
38
+ return @rel.public_send(method, ...) unless @rel.respond_to?(method)
39
39
 
40
40
  preamble = <<-EOS
41
- def #{method}(*margs, &mblock)
42
- return @rel.#{method}(*margs, &mblock) unless @current_shard
41
+ def #{method}(*, **, &mblock)
42
+ return @rel.#{method}(*, **, &mblock) unless @current_shard
43
43
  EOS
44
44
  postamble = <<-EOS
45
45
  return ret unless ret.is_a?(::ActiveRecord::Relation) || ret.is_a?(::ActiveRecord::QueryMethods::WhereChain) || ret.is_a?(::Enumerator)
46
46
  ::Octoball::RelationProxy.new(ret, @current_shard)
47
47
  end
48
- ruby2_keywords(:#{method}) if respond_to?(:ruby2_keywords, true)
49
48
  EOS
50
49
  connected_to = '::ActiveRecord::Base.connected_to(role: ::Octoball.current_role, shard: @current_shard)'
51
50
 
52
51
  if ENUM_METHODS.include?(method)
53
52
  ::Octoball::RelationProxy.class_eval <<-EOS, __FILE__, __LINE__ - 1
54
53
  #{preamble}
55
- ret = #{connected_to} { @rel.to_a }.#{method}(*margs, &mblock)
54
+ ret = #{connected_to} { @rel.to_a }.#{method}(*, **, &mblock)
56
55
  #{postamble}
57
56
  EOS
58
57
  elsif ENUM_WITH_BLOCK_METHODS.include?(method)
@@ -60,9 +59,9 @@ class Octoball
60
59
  #{preamble}
61
60
  ret = nil
62
61
  if mblock
63
- ret = #{connected_to} { @rel.to_a }.#{method}(*margs, &mblock)
62
+ ret = #{connected_to} { @rel.to_a }.#{method}(*, **, &mblock)
64
63
  else
65
- #{connected_to} { ret = @rel.#{method}(*margs, &mblock); nil } # return nil to avoid loading relation
64
+ #{connected_to} { ret = @rel.#{method}(*, **, &mblock); nil } # return nil to avoid loading relation
66
65
  end
67
66
  #{postamble}
68
67
  EOS
@@ -70,14 +69,13 @@ class Octoball
70
69
  ::Octoball::RelationProxy.class_eval <<-EOS, __FILE__, __LINE__ - 1
71
70
  #{preamble}
72
71
  ret = nil
73
- #{connected_to} { ret = @rel.#{method}(*margs, &mblock); nil } # return nil to avoid loading relation
72
+ #{connected_to} { ret = @rel.#{method}(*, **, &mblock); nil } # return nil to avoid loading relation
74
73
  #{postamble}
75
74
  EOS
76
75
  end
77
76
 
78
- public_send(method, *args, &block)
77
+ public_send(method, ...)
79
78
  end
80
- ruby2_keywords(:method_missing) if respond_to?(:ruby2_keywords, true)
81
79
 
82
80
  def inspect
83
81
  return @rel.inspect unless @current_shard
@@ -1,6 +1,6 @@
1
1
  class Octoball
2
- def self.using(shard, &block)
3
- ActiveRecord::Base.connected_to(role: current_role, shard: shard&.to_sym, &block)
2
+ def self.using(shard, &)
3
+ ActiveRecord::Base.connected_to(role: current_role, shard: shard&.to_sym, &)
4
4
  end
5
5
 
6
6
  def self.current_role
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Octoball
4
- VERSION = '0.1.8'
4
+ VERSION = '0.1.9'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octoball
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoki Sekiyama
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubygems_version: 3.7.0.dev
172
+ rubygems_version: 4.0.10
173
173
  specification_version: 4
174
174
  summary: Octopus-like Database Sharding Helper for ActiveRecord 6.1+
175
175
  test_files: []