pg_party 0.7.1 → 0.7.2

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
  SHA1:
3
- metadata.gz: 0d8a08047a1190e154ea5e76a4cf5bafdad17829
4
- data.tar.gz: 25a9a8be75f915006c1f36aa5f6cb2eb8111cb12
3
+ metadata.gz: 2eee444e0ce9baf767d5726bfe1c3f0a53fec0d7
4
+ data.tar.gz: 3c22b58fc7dceba390af9a2f7625c6e37ef0cb5a
5
5
  SHA512:
6
- metadata.gz: 809f31226645fb6f22062d3aa1f2df143ad56798aeb94e65513f7937a451d52527dbe8116ec893a1936c75dd93bb17ea52165a311e341832538810f059d0527f
7
- data.tar.gz: 070e5afc308dea1aef85f7de3c3f3b34ca586ceda999de73c9aaf787310e7d6425fe359df4f026be6260684d3d2c6e6f80ee166d7cf7e4df576c3a2313dee298
6
+ metadata.gz: 8628f4d972a5fb485d96392704d5a63677c37da498599620a984a67e79778f05d4b4534c84a2ba9788290c6777eee5851cd8f2fa08fa86101ecfad8e496f0da8
7
+ data.tar.gz: 05476083807bc9bd20773c445f44a2a821de1135faca48e235854220172960251925305d3dadfac90fe37c843c028754a38f97a973aad2cec3496e3c11efb77b
@@ -11,15 +11,15 @@ module PgParty
11
11
  nil
12
12
  end
13
13
 
14
- def fetch_model(parent_table, child_table, &block)
14
+ def fetch_model(key, child_table, &block)
15
15
  LOCK.synchronize do
16
- store[parent_table.to_sym][:models][child_table.to_sym] ||= block.call
16
+ store[key][:models][child_table.to_sym] ||= block.call
17
17
  end
18
18
  end
19
19
 
20
- def fetch_partitions(table_name, &block)
20
+ def fetch_partitions(key, &block)
21
21
  LOCK.synchronize do
22
- store[table_name.to_sym][:partitions] ||= block.call
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 a table name that doesn't exist
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(table_name, child_table_name) do
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(table_name) do
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)
@@ -1,3 +1,3 @@
1
1
  module PgParty
2
- VERSION = "0.7.1"
2
+ VERSION = "0.7.2"
3
3
  end
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.1
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-02 00:00:00.000000000 Z
11
+ date: 2017-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord