class OpalORM::Util
Public Class Methods
config_path()
click to toggle source
# File lib/opal_orm/util.rb, line 17 def self.config_path File.join(self.db_path, 'opal_config.json') end
current_path()
click to toggle source
# File lib/opal_orm/util.rb, line 9 def self.current_path Dir.pwd end
db_path()
click to toggle source
# File lib/opal_orm/util.rb, line 13 def self.db_path File.join(self.current_path, 'db') end
ensure_db_dir()
click to toggle source
# File lib/opal_orm/util.rb, line 3 def self.ensure_db_dir unless Dir.exist?(self.db_path) Dir.mkdir('db') end end
get_config()
click to toggle source
# File lib/opal_orm/util.rb, line 21 def self.get_config if File.exists?(Util.config_path) JSON.parse(File.read(Util.config_path))|| {} end end
get_database_path()
click to toggle source
# File lib/opal_orm/util.rb, line 27 def self.get_database_path db_name = get_config["db_name"] if db_name File.join(db_path, db_name) end end
make_config()
click to toggle source
# File lib/opal_orm/util.rb, line 34 def self.make_config Util.ensure_db_dir unless File.exists?(Util.config_path) File.new(Util.config_path, 'w') end end
save_config(new_config)
click to toggle source
# File lib/opal_orm/util.rb, line 42 def self.save_config(new_config) File.open(Util.config_path, "w+") do |f| f.write(new_config.to_json) end end