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
66 67 68 |
# File 'lib/switchman/default_shard.rb', line 66 def self._load(_str) Shard.default end |
.instance ⇒ Object
77 78 79 |
# File 'lib/switchman/default_shard.rb', line 77 def instance @instance ||= new end |
Instance Method Details
#==(other) ⇒ Object
70 71 72 73 74 |
# File 'lib/switchman/default_shard.rb', line 70 def ==(other) return true if other.is_a?(DefaultShard) || (other.is_a?(Shard) && other[:default]) super end |
#_dump(_depth) ⇒ Object
62 63 64 |
# File 'lib/switchman/default_shard.rb', line 62 def _dump(_depth) '' end |
#activate(*_classes) ⇒ Object
11 12 13 |
# File 'lib/switchman/default_shard.rb', line 11 def activate(*_classes) yield end |
#activate!(*classes) ⇒ Object
15 |
# File 'lib/switchman/default_shard.rb', line 15 def activate!(*classes); end |
#database_server ⇒ Object
37 38 39 |
# File 'lib/switchman/default_shard.rb', line 37 def database_server DatabaseServer.find(nil) end |
#database_server_id ⇒ Object
33 34 35 |
# File 'lib/switchman/default_shard.rb', line 33 def database_server_id nil end |
#default? ⇒ Boolean
17 18 19 |
# File 'lib/switchman/default_shard.rb', line 17 def default? true end |
#description ⇒ Object
53 54 55 |
# File 'lib/switchman/default_shard.rb', line 53 def description ::Rails.env end |
#global_id_for(local_id) ⇒ Object
29 30 31 |
# File 'lib/switchman/default_shard.rb', line 29 def global_id_for(local_id) local_id end |
#id ⇒ Object Also known as: cache_key
7 8 9 |
# File 'lib/switchman/default_shard.rb', line 7 def id 'default' end |
#name ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/switchman/default_shard.rb', line 45 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
41 42 43 |
# File 'lib/switchman/default_shard.rb', line 41 def new_record? false end |
#primary? ⇒ Boolean
21 22 23 |
# File 'lib/switchman/default_shard.rb', line 21 def primary? true end |
#relative_id_for(local_id, _target = nil) ⇒ Object
25 26 27 |
# File 'lib/switchman/default_shard.rb', line 25 def relative_id_for(local_id, _target = nil) local_id end |
#shard ⇒ Object
The default’s shard is always the default shard
58 59 60 |
# File 'lib/switchman/default_shard.rb', line 58 def shard self end |