Sha256: f705eecb43d84ed77ee0f368c00ccdb201211cd1b0656ae14cd926b584f98c6c
Contents?: true
Size: 1.02 KB
Versions: 17
Compression:
Stored size: 1.02 KB
Contents
module Khronos class Storage module Adapter @frameworks = { 'mongodb' => 'mongoid', 'postgresql' => 'activerecord', 'mysql2' => 'activerecord', 'sqlite3' => 'activerecord' } @classes = { 'activerecord' => 'ActiveRecord', 'mongoid' => 'Mongoid' } @adapters = { 'mongodb' => 'mongoid' } def self.parse_uri(uri) data = URI.parse(uri) { :scheme => data.scheme, :host => data.host, :user => data.user, :password => data.password, :path => data.path } end def self.get(url) uri = parse_uri(url) framework = @frameworks[uri[:scheme]] require "khronos/storage/adapter/#{framework}" # Get and connect with the adapter class. adapter = const_get(@classes[framework]) # uri.merge(:adapter => @adapters[uri[:scheme]] || uri[:scheme]) adapter.connect!(url) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems