Sha256: 7d921956bdc306e8d35e1d79065784832b852cb5b345069473d09d249e299a2a
Contents?: true
Size: 455 Bytes
Versions: 8
Compression:
Stored size: 455 Bytes
Contents
require_relative 'environment' class SQLRunner COMMANDS = ["create", "insert", "update", "delete"] def initialize(db) @db = db end def self.make_methods COMMANDS.each do |command| define_method("execute_sql_#{command}") do sql = File.read("lib/#{command}.sql") execute_sql(sql) end end end def execute_sql(sql) sql.scan(/[^;]*;/m).each { |line| @db.execute(line) } unless sql.empty? end end
Version data entries
8 entries across 8 versions & 1 rubygems