active_record_shards 3.9.0 → 3.9.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
  SHA1:
3
- metadata.gz: 9a95ee1107402ac016dcd5dbe7caf84b77973c5e
4
- data.tar.gz: 7871eaecc9cf5971d2b1a35f002a8c0c82b1951c
3
+ metadata.gz: 5eaf3339acdbdbfd5a5e69de209999bcdee61f0a
4
+ data.tar.gz: 0c08479308dd97ec3b96d319582a7ba967142727
5
5
  SHA512:
6
- metadata.gz: edb32557a10fce0738d2015bcf4e747f00ec1b49cc72a99c1cbbfbd3d4583a202e19087abb374e434bd87387e7e0ef5e584b046ca2888d0fc6774c63e026ac6c
7
- data.tar.gz: bd8d79125096f2228cf4d862b3fac99b346c303b4f4304d70c7294906c239a5b85f2342d7721984413879541620c6927ee64c4320fbb8ee53649f2f09143c8e0
6
+ metadata.gz: 258f24f35992d4bc243c0e7076346c4da3777be04de94feb7bb86b1d07956d0e2329474d7b912aaca8bfe2fd58f99aac551fb26a8419cb13c97f807548f194c5
7
+ data.tar.gz: 422849bea3e139723574b745eb1dae664d19e5d8e4eb48bda314f0841c39aa86497cd52113f4fc7049a918429d122962cfd3ec5bad044792446c90caaa4c8732
@@ -9,13 +9,14 @@ module ActiveRecordShards
9
9
  end
10
10
 
11
11
  def is_sharded? # rubocop:disable Style/PredicateName
12
+ sharded_ivar = defined?(@sharded) ? @sharded : nil
12
13
  if self == ActiveRecord::Base
13
- @sharded != false && supports_sharding?
14
+ sharded_ivar != false && supports_sharding?
14
15
  elsif self == base_class
15
- if @sharded.nil?
16
+ if sharded_ivar.nil?
16
17
  ActiveRecord::Base.is_sharded?
17
18
  else
18
- @sharded != false
19
+ sharded_ivar != false
19
20
  end
20
21
  else
21
22
  base_class.is_sharded?
@@ -26,16 +27,12 @@ module ActiveRecordShards
26
27
  if self == ActiveRecord::Base
27
28
  false
28
29
  elsif self == base_class
29
- @on_slave_by_default
30
+ on_slave_by_default
30
31
  else
31
32
  base_class.on_slave_by_default?
32
33
  end
33
34
  end
34
35
 
35
- def on_slave_by_default=(val)
36
- @on_slave_by_default = val
37
- end
38
-
39
36
  module InstanceMethods
40
37
  def initialize_shard_and_slave
41
38
  @from_slave = !!self.class.current_shard_selection.options[:slave]
@@ -55,5 +52,11 @@ module ActiveRecordShards
55
52
  base.send(:include, InstanceMethods)
56
53
  base.after_initialize :initialize_shard_and_slave
57
54
  end
55
+
56
+ attr_writer :on_slave_by_default
57
+
58
+ private
59
+
60
+ attr_reader :on_slave_by_default
58
61
  end
59
62
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_shards
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.0
4
+ version: 3.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-21 00:00:00.000000000 Z
13
+ date: 2017-03-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '12.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '12.0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: mysql2
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -228,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
228
  version: '0'
229
229
  requirements: []
230
230
  rubyforge_project:
231
- rubygems_version: 2.5.2
231
+ rubygems_version: 2.6.11
232
232
  signing_key:
233
233
  specification_version: 4
234
234
  summary: Simple database switching for ActiveRecord.