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



75
76
77
# File 'lib/switchman/default_shard.rb', line 75

def self._load(_str)
  Shard.default
end

.instanceObject



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_serverObject



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

def database_server
  DatabaseServer.find(nil)
end

#database_server_idObject



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

def database_server_id
  nil
end

#default?Boolean

Returns:

  • (Boolean)


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

def default?
  true
end

#descriptionObject



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

#idObject Also known as: cache_key



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

def id
  "default"
end

#in_current_region?Boolean

Returns:

  • (Boolean)


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

def in_current_region?
  true
end

#in_region?(_region) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/switchman/default_shard.rb', line 63

def in_region?(_region)
  true
end

#nameObject



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

Returns:

  • (Boolean)


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

def new_record?
  false
end

#primary?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/switchman/default_shard.rb', line 20

def primary?
  true
end

#regionObject



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

#shardObject

The default’s shard is always the default shard



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

def shard
  self
end