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



66
67
68
# File 'lib/switchman/default_shard.rb', line 66

def self._load(_str)
  Shard.default
end

.instanceObject



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_serverObject



37
38
39
# File 'lib/switchman/default_shard.rb', line 37

def database_server
  DatabaseServer.find(nil)
end

#database_server_idObject



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

def database_server_id
  nil
end

#default?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/switchman/default_shard.rb', line 17

def default?
  true
end

#descriptionObject



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

#idObject Also known as: cache_key



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

def id
  'default'
end

#nameObject



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

Returns:

  • (Boolean)


41
42
43
# File 'lib/switchman/default_shard.rb', line 41

def new_record?
  false
end

#primary?Boolean

Returns:

  • (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

#shardObject

The default’s shard is always the default shard



58
59
60
# File 'lib/switchman/default_shard.rb', line 58

def shard
  self
end