octoball 0.1.3 → 0.1.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 +4 -4
- data/.circleci/Gemfile +8 -0
- data/.circleci/config.yml +3 -1
- data/lib/octoball/association.rb +7 -0
- data/lib/octoball/version.rb +1 -1
- data/spec/octoball/relation_proxy_spec.rb +14 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 260d7c95bac1ba724636272cfa7ecf444124b868b2c7a3cea4d6966e0ac947a9
|
4
|
+
data.tar.gz: 5036fc1b1f6f5f0d7b24c734951ad6cbff0fd48eabc529a3f5390e55f2ad50d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d954e47f0a2603425d29e82669b9388d4f49abf7def04e268548554ee5ab52181a2b192a5ccfd34b288a67b34fd6cf8cac4d75b8304c918970f7523f3177285
|
7
|
+
data.tar.gz: 7b294deea783c80324d5694afd87984017411677f593d042fa9b78a35e5dba5d12584209bb36d45190c3e63d748e1a4f5096e6a6e992ef9ebfa71e7968a41c4d
|
data/.circleci/Gemfile
ADDED
data/.circleci/config.yml
CHANGED
@@ -26,8 +26,9 @@ jobs:
|
|
26
26
|
name: bundle install
|
27
27
|
command: |
|
28
28
|
gem update bundler
|
29
|
+
bundle config --local path ../vendor/bundle
|
30
|
+
bundle install --gemfile .circleci/Gemfile --jobs=4 --retry=3
|
29
31
|
bundle config --local path vendor/bundle
|
30
|
-
bundle install --jobs=4 --retry=3
|
31
32
|
- run:
|
32
33
|
name: Setup databases
|
33
34
|
command: bundle exec rake db:prepare
|
@@ -44,3 +45,4 @@ workflows:
|
|
44
45
|
parameters:
|
45
46
|
version:
|
46
47
|
- "2.7"
|
48
|
+
- "3.0"
|
data/lib/octoball/association.rb
CHANGED
@@ -5,6 +5,12 @@ class Octoball
|
|
5
5
|
attr_accessor :current_shard
|
6
6
|
end
|
7
7
|
|
8
|
+
module RelationProxyIsARelation
|
9
|
+
def ===(other)
|
10
|
+
other.is_a?(self)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
8
14
|
module ShardedCollectionAssociation
|
9
15
|
[:writer, :ids_reader, :ids_writer, :create, :create!,
|
10
16
|
:build, :include?, :load_target, :reload, :size, :select].each do |method|
|
@@ -71,6 +77,7 @@ class Octoball
|
|
71
77
|
end
|
72
78
|
|
73
79
|
::ActiveRecord::Relation.prepend(RelationCurrentShard)
|
80
|
+
::ActiveRecord::Relation.singleton_class.prepend(RelationProxyIsARelation)
|
74
81
|
::ActiveRecord::QueryMethods::WhereChain.prepend(RelationCurrentShard)
|
75
82
|
::ActiveRecord::Associations::CollectionAssociation.prepend(ShardedCollectionAssociation)
|
76
83
|
::ActiveRecord::Associations::CollectionProxy.singleton_class.prepend(ShardedCollectionProxyCreate)
|
data/lib/octoball/version.rb
CHANGED
@@ -52,6 +52,20 @@ describe Octoball::RelationProxy do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
context 'when a relation is used in where clause' do
|
56
|
+
it 'specifies the scope without a shard' do
|
57
|
+
client = Client.where(id: @client.id)
|
58
|
+
items = Item.using(:canada).where(client: client)
|
59
|
+
expect(items.to_a).to eq(@client.items.to_a)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'specifies the scope with a shard' do
|
63
|
+
client = Client.using(:canada).where(id: @client.id)
|
64
|
+
items = Item.using(:canada).where(client: client)
|
65
|
+
expect(items.to_a).to eq(@client.items.to_a)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
55
69
|
context 'when comparing to other Relation objects' do
|
56
70
|
before :each do
|
57
71
|
@relation.reset
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octoball
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomoki Sekiyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -116,6 +116,7 @@ executables: []
|
|
116
116
|
extensions: []
|
117
117
|
extra_rdoc_files: []
|
118
118
|
files:
|
119
|
+
- ".circleci/Gemfile"
|
119
120
|
- ".circleci/config.yml"
|
120
121
|
- ".gitignore"
|
121
122
|
- Gemfile
|
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
168
|
- !ruby/object:Gem::Version
|
168
169
|
version: '0'
|
169
170
|
requirements: []
|
170
|
-
rubygems_version: 3.1.
|
171
|
+
rubygems_version: 3.1.6
|
171
172
|
signing_key:
|
172
173
|
specification_version: 4
|
173
174
|
summary: Octopus-like Database Sharding Helper for ActiveRecord 6.1+
|