Class: Switchman::DefaultShard
- Inherits:
-
Object
- Object
- Switchman::DefaultShard
- Defined in:
- lib/switchman/default_shard.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #_dump(_depth) ⇒ Object
- #activate(*_classes) ⇒ Object
- #activate!(*classes) ⇒ Object
- #database_server ⇒ Object
- #database_server_id ⇒ Object
- #default? ⇒ Boolean
- #description ⇒ Object
- #global_id_for(local_id) ⇒ Object
- #id ⇒ Object (also: #cache_key)
- #name ⇒ Object
- #new_record? ⇒ Boolean
- #primary? ⇒ Boolean
- #relative_id_for(local_id, _target = nil) ⇒ Object
-
#shard ⇒ Object
The default’s shard is always the default shard.
Class Method Details
._load(_str) ⇒ Object
64 65 66 |
# File 'lib/switchman/default_shard.rb', line 64 def self._load(_str) Shard.default end |
.instance ⇒ Object
75 76 77 |
# File 'lib/switchman/default_shard.rb', line 75 def instance @instance ||= new end |
Instance Method Details
#==(other) ⇒ Object
68 69 70 71 72 |
# File 'lib/switchman/default_shard.rb', line 68 def ==(other) return true if other.is_a?(DefaultShard) || (other.is_a?(Shard) && other[:default]) super end |
#_dump(_depth) ⇒ Object
60 61 62 |
# File 'lib/switchman/default_shard.rb', line 60 def _dump(_depth) '' end |
#activate(*_classes) ⇒ Object
9 10 11 |
# File 'lib/switchman/default_shard.rb', line 9 def activate(*_classes) yield end |
#activate!(*classes) ⇒ Object
13 |
# File 'lib/switchman/default_shard.rb', line 13 def activate!(*classes); end |
#database_server ⇒ Object
35 36 37 |
# File 'lib/switchman/default_shard.rb', line 35 def database_server DatabaseServer.find(nil) end |
#database_server_id ⇒ Object
31 32 33 |
# File 'lib/switchman/default_shard.rb', line 31 def database_server_id nil end |
#default? ⇒ Boolean
15 16 17 |
# File 'lib/switchman/default_shard.rb', line 15 def default? true end |
#description ⇒ Object
51 52 53 |
# File 'lib/switchman/default_shard.rb', line 51 def description ::Rails.env end |
#global_id_for(local_id) ⇒ Object
27 28 29 |
# File 'lib/switchman/default_shard.rb', line 27 def global_id_for(local_id) local_id end |
#id ⇒ Object Also known as: cache_key
5 6 7 |
# File 'lib/switchman/default_shard.rb', line 5 def id 'default' end |
#name ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/switchman/default_shard.rb', line 43 def name unless instance_variable_defined?(:@name) @name = nil # prevent taking this branch on recursion @name = database_server.shard_name(:bootstrap) end @name end |
#new_record? ⇒ Boolean
39 40 41 |
# File 'lib/switchman/default_shard.rb', line 39 def new_record? false end |
#primary? ⇒ Boolean
19 20 21 |
# File 'lib/switchman/default_shard.rb', line 19 def primary? true end |
#relative_id_for(local_id, _target = nil) ⇒ Object
23 24 25 |
# File 'lib/switchman/default_shard.rb', line 23 def relative_id_for(local_id, _target = nil) local_id end |
#shard ⇒ Object
The default’s shard is always the default shard
56 57 58 |
# File 'lib/switchman/default_shard.rb', line 56 def shard self end |