Class: Switchman::DefaultShard

Inherits:
Object
  • Object
show all
Defined in:
lib/switchman/default_shard.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

._load(str) ⇒ Object



29
30
31
# File 'lib/switchman/default_shard.rb', line 29

def self._load(str)
  Shard.default
end

.instanceObject



39
40
41
# File 'lib/switchman/default_shard.rb', line 39

def instance
  @instance ||= new
end

Instance Method Details

#==(rhs) ⇒ Object



33
34
35
36
# File 'lib/switchman/default_shard.rb', line 33

def ==(rhs)
  return true if rhs.is_a?(DefaultShard) || (rhs.is_a?(Shard) && rhs[:default])
  super
end

#_dump(depth) ⇒ Object



26
27
28
# File 'lib/switchman/default_shard.rb', line 26

def _dump(depth)
  ''
end

#activate(*categories) ⇒ Object



7
# File 'lib/switchman/default_shard.rb', line 7

def activate(*categories); yield; end

#activate!(*categories) ⇒ Object



8
# File 'lib/switchman/default_shard.rb', line 8

def activate!(*categories); end

#database_serverObject



14
# File 'lib/switchman/default_shard.rb', line 14

def database_server; DatabaseServer.find(nil); end

#database_server_idObject



13
# File 'lib/switchman/default_shard.rb', line 13

def database_server_id; nil; end

#default?Boolean

Returns:

  • (Boolean)


9
# File 'lib/switchman/default_shard.rb', line 9

def default?; true; end

#descriptionObject



23
# File 'lib/switchman/default_shard.rb', line 23

def description; ::Rails.env; end

#global_id_for(local_id) ⇒ Object



12
# File 'lib/switchman/default_shard.rb', line 12

def global_id_for(local_id); local_id; end

#idObject Also known as: cache_key



5
# File 'lib/switchman/default_shard.rb', line 5

def id; 'default'; end

#nameObject



16
17
18
19
20
21
22
# File 'lib/switchman/default_shard.rb', line 16

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

Returns:

  • (Boolean)


15
# File 'lib/switchman/default_shard.rb', line 15

def new_record?; false; end

#primary?Boolean

Returns:

  • (Boolean)


10
# File 'lib/switchman/default_shard.rb', line 10

def primary?; true; end

#relative_id_for(local_id, target = nil) ⇒ Object



11
# File 'lib/switchman/default_shard.rb', line 11

def relative_id_for(local_id, target = nil); local_id; end

#shardObject

The default’s shard is always the default shard



25
# File 'lib/switchman/default_shard.rb', line 25

def shard; self; end