Module: XBar::Model

Extended by:
ActiveSupport::Concern
Defined in:
lib/xbar/model.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#connection_proxyObject



27
28
29
# File 'lib/xbar/model.rb', line 27

def connection_proxy
  self.class.connection_proxy
end

#reload_connectionObject



40
41
42
43
# File 'lib/xbar/model.rb', line 40

def reload_connection
  return unless should_set_current_shard?
  connection_proxy.current_shard = current_shard
end

#reload_connection_safeObject



31
32
33
34
35
36
37
38
# File 'lib/xbar/model.rb', line 31

def reload_connection_safe
  return yield unless should_set_current_shard?
  original = connection_proxy.current_shard
  connection_proxy.current_shard = current_shard
  result = yield
  connection_proxy.current_shard = original
  result
end

#should_set_current_shard?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/xbar/model.rb', line 23

def should_set_current_shard?
  current_shard
end