require 'sequel' module Legion module Data class Connection attr_accessor :database def initialize(options = {}) options.merge!(default_options) { |_key, v1, _v2| v1 } return unless options[:auto_connect] jruby(options) if RUBY_ENGINE == 'jruby' mri(options) unless RUBY_ENGINE == 'jruby' end def default_options { auto_connect: true } end def jruby(_options = {}) require 'legion/data/connections/jdbc' @database = Legion::Data::Connections::JDBC.new end def mri(_options = {}) require 'legion/data/connections/mysql2' @database = Legion::Data::Connections::MySQL2.new end end end end