Sha256: 322cf2b230b52700ee5e7deba2f3b8ad3476fac27f00edfe7dad91f880db69ae
Contents?: true
Size: 686 Bytes
Versions: 2
Compression:
Stored size: 686 Bytes
Contents
# frozen_string_literal: true require 'mysql2' class DBDataSource private_class_method :new @instance_mutex = Mutex.new def initialize db_config = YAML.load_file('./LabStudents/db_config/config.yaml').transform_keys(&:to_sym) @client = Mysql2::Client.new(db_config) @client.query_options.merge!(symbolize_keys: true) end def self.instance return @instance if @instance @instance_mutex.synchronize do @instance ||= new end @instance end def prepare_exec(statement, *params) @client.prepare(statement).execute(*params) end def query(statement) @client.query(statement) end def last_id @client.last_id end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubbish_code-1.0.0 | lib/source/repositories/data_sources/db_data_source.rb |
rubbish_code-0.1.4 | lib/source/repositories/data_sources/db_data_source.rb |