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



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

def self._load(_str)
  Shard.default
end

.instanceObject



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

def instance
  @instance ||= new
end

Instance Method Details

#==(other) ⇒ Object



68
69
70
71
72
# File 'lib/switchman/default_shard.rb', line 68

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

  super
end

#_dump(_depth) ⇒ Object



60
61
62
# File 'lib/switchman/default_shard.rb', line 60

def _dump(_depth)
  ""
end

#activate(*_classes) ⇒ Object



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

def activate(*_classes)
  yield
end

#activate!(*classes) ⇒ Object



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

def activate!(*classes); end

#database_serverObject



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

def database_server
  DatabaseServer.find(nil)
end

#database_server_idObject



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

def database_server_id
  nil
end

#default?Boolean

Returns:

  • (Boolean)


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

def default?
  true
end

#descriptionObject



51
52
53
# File 'lib/switchman/default_shard.rb', line 51

def description
  ::Rails.env
end

#global_id_for(local_id) ⇒ Object



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

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

#nameObject



43
44
45
46
47
48
49
# File 'lib/switchman/default_shard.rb', line 43

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)


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

def new_record?
  false
end

#primary?Boolean

Returns:

  • (Boolean)


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

def primary?
  true
end

#relative_id_for(local_id, _target = nil) ⇒ Object



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

def relative_id_for(local_id, _target = nil)
  local_id
end

#shardObject

The default’s shard is always the default shard



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

def shard
  self
end