Created
August 21, 2014 08:58
-
-
Save andrius/857ed4afa1b78cb0f5f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Configuration | |
Error = Class.new StandardError | |
class << self | |
def config(&block) | |
@config ||= initialize_config | |
block_given? and yield @config | |
@config | |
end | |
def initialize_config | |
_config = OpenStruct.new | |
end | |
def config=(config) | |
@config = config | |
end | |
end | |
end | |
# project directory and name | |
Configuration.config.app_root = File.expand_path( File.dirname(__FILE__) + '/..' ) | |
Configuration.config.app_name = Configuration.config.app_root.split('/')[-1] | |
# loading database | |
require_relative '../config/database' | |
Configuration.config.database = Sequel.connect(Configuration.config.database_url) | |
######################################################################################## | |
# config/database.rb | |
######################################################################################## | |
Configuration.config do |config| | |
config.database_url = "sqlite:///#{config.app_root}/db/development.sqlite3" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment