Module: ConnectionManager::Using::ClassMethods

Defined in:
lib/connection_manager/using.rb

Instance Method Summary collapse

Instance Method Details

#fetch_duplicate_class(connection_class_name) ⇒ Object

We use dup here because its just too tricky to make sure we override all the methods necessary when using a child class of the model. This action is lazy and the created sub is named to a constant so we only have to do it once.



10
11
12
13
14
15
16
# File 'lib/connection_manager/using.rb', line 10

def fetch_duplicate_class(connection_class_name)
  begin
    return "#{self.name}::#{connection_class_name}Dup".constantize
  rescue NameError
    return build_dup_class(connection_class_name)
  end
end