Class: Switchman::DefaultShard
- Inherits:
-
Object
- Object
- Switchman::DefaultShard
- Defined in:
- lib/switchman/default_shard.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(rhs) ⇒ Object
- #_dump(depth) ⇒ Object
- #activate(*categories) ⇒ Object
- #activate!(*categories) ⇒ 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
31 32 33 |
# File 'lib/switchman/default_shard.rb', line 31 def self._load(str) Shard.default end |
.instance ⇒ Object
41 42 43 |
# File 'lib/switchman/default_shard.rb', line 41 def instance @instance ||= new end |
Instance Method Details
#==(rhs) ⇒ Object
35 36 37 38 |
# File 'lib/switchman/default_shard.rb', line 35 def ==(rhs) return true if rhs.is_a?(DefaultShard) || (rhs.is_a?(Shard) && rhs[:default]) super end |
#_dump(depth) ⇒ Object
28 29 30 |
# File 'lib/switchman/default_shard.rb', line 28 def _dump(depth) '' end |
#activate(*categories) ⇒ Object
9 |
# File 'lib/switchman/default_shard.rb', line 9 def activate(*categories); yield; end |
#activate!(*categories) ⇒ Object
10 |
# File 'lib/switchman/default_shard.rb', line 10 def activate!(*categories); end |
#database_server ⇒ Object
16 |
# File 'lib/switchman/default_shard.rb', line 16 def database_server; DatabaseServer.find(nil); end |
#database_server_id ⇒ Object
15 |
# File 'lib/switchman/default_shard.rb', line 15 def database_server_id; nil; end |
#default? ⇒ Boolean
11 |
# File 'lib/switchman/default_shard.rb', line 11 def default?; true; end |
#description ⇒ Object
25 |
# File 'lib/switchman/default_shard.rb', line 25 def description; ::Rails.env; end |
#global_id_for(local_id) ⇒ Object
14 |
# File 'lib/switchman/default_shard.rb', line 14 def global_id_for(local_id); local_id; end |
#id ⇒ Object Also known as: cache_key
7 |
# File 'lib/switchman/default_shard.rb', line 7 def id; 'default'; end |
#name ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/switchman/default_shard.rb', line 18 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
17 |
# File 'lib/switchman/default_shard.rb', line 17 def new_record?; false; end |
#primary? ⇒ Boolean
12 |
# File 'lib/switchman/default_shard.rb', line 12 def primary?; true; end |
#relative_id_for(local_id, target = nil) ⇒ Object
13 |
# File 'lib/switchman/default_shard.rb', line 13 def relative_id_for(local_id, target = nil); local_id; end |
#shard ⇒ Object
The default’s shard is always the default shard
27 |
# File 'lib/switchman/default_shard.rb', line 27 def shard; self; end |