Module: Octopus::Model::SharedMethods

Included in:
ClassMethods, InstanceMethods
Defined in:
lib/octopus/model.rb

Instance Method Summary collapse

Instance Method Details

#clean_table_nameObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/octopus/model.rb', line 12

def clean_table_name
  return unless connection_proxy.should_clean_table_name?

  if self != ActiveRecord::Base && self.respond_to?(:reset_table_name) && !custom_octopus_table_name
    reset_table_name
  end

  reset_column_information
  instance_variable_set(:@quoted_table_name, nil)
end

#using(shard) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/octopus/model.rb', line 23

def using(shard)
  if Octopus.enabled?
    clean_table_name
    Octopus::ScopeProxy.new(shard, self)
  else
    self
  end
end