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)
- #in_current_region? ⇒ Boolean
- #in_region?(_region) ⇒ Boolean
- #name ⇒ Object
- #new_record? ⇒ Boolean
- #primary? ⇒ Boolean
- #region ⇒ Object
- #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
75 76 77 |
# File 'lib/switchman/default_shard.rb', line 75 def self._load(_str) Shard.default end |
.instance ⇒ Object
86 87 88 |
# File 'lib/switchman/default_shard.rb', line 86 def instance @instance ||= new end |
Instance Method Details
#==(other) ⇒ Object
79 80 81 82 83 |
# File 'lib/switchman/default_shard.rb', line 79 def ==(other) return true if other.is_a?(DefaultShard) || (other.is_a?(Shard) && other[:default]) super end |
#_dump(_depth) ⇒ Object
71 72 73 |
# File 'lib/switchman/default_shard.rb', line 71 def _dump(_depth) "" end |
#activate(*_classes) ⇒ Object
10 11 12 |
# File 'lib/switchman/default_shard.rb', line 10 def activate(*_classes) yield end |
#activate!(*classes) ⇒ Object
14 |
# File 'lib/switchman/default_shard.rb', line 14 def activate!(*classes); end |
#database_server ⇒ Object
36 37 38 |
# File 'lib/switchman/default_shard.rb', line 36 def database_server DatabaseServer.find(nil) end |
#database_server_id ⇒ Object
32 33 34 |
# File 'lib/switchman/default_shard.rb', line 32 def database_server_id nil end |
#default? ⇒ Boolean
16 17 18 |
# File 'lib/switchman/default_shard.rb', line 16 def default? true end |
#description ⇒ Object
52 53 54 |
# File 'lib/switchman/default_shard.rb', line 52 def description ::Rails.env end |
#global_id_for(local_id) ⇒ Object
28 29 30 |
# File 'lib/switchman/default_shard.rb', line 28 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 |
#in_current_region? ⇒ Boolean
67 68 69 |
# File 'lib/switchman/default_shard.rb', line 67 def in_current_region? true end |
#in_region?(_region) ⇒ Boolean
63 64 65 |
# File 'lib/switchman/default_shard.rb', line 63 def in_region?(_region) true end |
#name ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/switchman/default_shard.rb', line 44 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
40 41 42 |
# File 'lib/switchman/default_shard.rb', line 40 def new_record? false end |
#primary? ⇒ Boolean
20 21 22 |
# File 'lib/switchman/default_shard.rb', line 20 def primary? true end |
#region ⇒ Object
61 |
# File 'lib/switchman/default_shard.rb', line 61 def region; end |
#relative_id_for(local_id, _target = nil) ⇒ Object
24 25 26 |
# File 'lib/switchman/default_shard.rb', line 24 def relative_id_for(local_id, _target = nil) local_id end |
#shard ⇒ Object
The default’s shard is always the default shard
57 58 59 |
# File 'lib/switchman/default_shard.rb', line 57 def shard self end |