Sha256: 422b0bcae0646bbbc572b9fd56ad8999bc9b3f4624fd1e1706d330f03fefde78

Contents?: true

Size: 517 Bytes

Versions: 2

Compression:

Stored size: 517 Bytes

Contents

module Slavery
  class ConnectionHolder < ActiveRecord::Base
    self.abstract_class = true

    class << self
      # for delayed activation
      def activate
        spec = ActiveRecord::Base.configurations[Slavery.spec_key]
        raise Error.new('Slavery.spec_key invalid!') if spec.nil?
        establish_connection spec
      end
    end
  end

  class << self
    def connection_holder
      @connection_holder ||= begin
        ConnectionHolder.activate
        ConnectionHolder
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slavery-2.1.1 lib/slavery/connection_holder.rb
slavery-2.1.0 lib/slavery/connection_holder.rb