pg_party 0.7.1 → 0.7.2
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/lib/pg_party/cache.rb +5 -5
- data/lib/pg_party/model_decorator.rb +6 -2
- data/lib/pg_party/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2eee444e0ce9baf767d5726bfe1c3f0a53fec0d7
|
4
|
+
data.tar.gz: 3c22b58fc7dceba390af9a2f7625c6e37ef0cb5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8628f4d972a5fb485d96392704d5a63677c37da498599620a984a67e79778f05d4b4534c84a2ba9788290c6777eee5851cd8f2fa08fa86101ecfad8e496f0da8
|
7
|
+
data.tar.gz: 05476083807bc9bd20773c445f44a2a821de1135faca48e235854220172960251925305d3dadfac90fe37c843c028754a38f97a973aad2cec3496e3c11efb77b
|
data/lib/pg_party/cache.rb
CHANGED
@@ -11,15 +11,15 @@ module PgParty
|
|
11
11
|
nil
|
12
12
|
end
|
13
13
|
|
14
|
-
def fetch_model(
|
14
|
+
def fetch_model(key, child_table, &block)
|
15
15
|
LOCK.synchronize do
|
16
|
-
store[
|
16
|
+
store[key][:models][child_table.to_sym] ||= block.call
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def fetch_partitions(
|
20
|
+
def fetch_partitions(key, &block)
|
21
21
|
LOCK.synchronize do
|
22
|
-
store[
|
22
|
+
store[key][:partitions] ||= block.call
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -27,7 +27,7 @@ module PgParty
|
|
27
27
|
|
28
28
|
def store
|
29
29
|
# automatically initialize a new hash when
|
30
|
-
# accessing
|
30
|
+
# accessing an object id that doesn't exist
|
31
31
|
@store ||= Hash.new { |h, k| h[k] = { models: {}, partitions: nil } }
|
32
32
|
end
|
33
33
|
end
|
@@ -19,7 +19,7 @@ module PgParty
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def in_partition(child_table_name)
|
22
|
-
PgParty::Cache.fetch_model(
|
22
|
+
PgParty::Cache.fetch_model(cache_key, child_table_name) do
|
23
23
|
Class.new(__getobj__) do
|
24
24
|
self.table_name = child_table_name
|
25
25
|
|
@@ -58,7 +58,7 @@ module PgParty
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def partitions
|
61
|
-
PgParty::Cache.fetch_partitions(
|
61
|
+
PgParty::Cache.fetch_partitions(cache_key) do
|
62
62
|
connection.select_values(<<-SQL)
|
63
63
|
SELECT pg_inherits.inhrelid::regclass::text
|
64
64
|
FROM pg_tables
|
@@ -92,6 +92,10 @@ module PgParty
|
|
92
92
|
|
93
93
|
private
|
94
94
|
|
95
|
+
def cache_key
|
96
|
+
__getobj__.object_id
|
97
|
+
end
|
98
|
+
|
95
99
|
def table_exists_method
|
96
100
|
[:data_source_exists?, :table_exists?].detect do |meth|
|
97
101
|
connection.schema_cache.respond_to?(meth)
|
data/lib/pg_party/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_party
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Krage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|