Sha256: ae2e4c4eee08229f308cb084328314334a072bef2f6b7d85d199128c24eba102
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
require 'active_support/core_ext/class/attribute' require 'active_support/concern' require_relative '../connection' require_relative '../configuration' module ActiveHouse module Modeling module Connection extend ActiveSupport::Concern included do class_attribute :_connection_class, instance_accessor: false class_attribute :_connection, instance_accessor: false self._connection_class = ActiveHouse::Connection end class_methods do def ensure_connection establish_connection if _connection.nil? end def establish_connection(name_or_config = nil) config = if name_or_config.is_a?(Hash) name_or_config.symbolize_keys else ActiveHouse.configuration.connection_config_for(name_or_config) end self._connection = _connection_class.new(config) end def connection ensure_connection _connection end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems