Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/active_record/fb_base.rb
Class Method Summary collapse
Class Method Details
.fb_connection(config) ⇒ Object
:nodoc:
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/active_record/fb_base.rb', line 3 def self.fb_connection(config) # :nodoc: require 'fb' config = fb_connection_config(config) db = ::Fb::Database.new(config) begin connection = db.connect rescue unless config[:create] require 'pp' pp config raise ConnectionNotEstablished, "No Firebird connections established." end connection = db.create.connect end ConnectionAdapters::FbAdapter.new(connection, logger, config) end |
.fb_connection_config(config) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/active_record/fb_base.rb', line 20 def self.fb_connection_config(config) config = config.symbolize_keys.dup.reverse_merge(:downcase_names => true, :port => 3050) fail ArgumentError, 'No database specified. Missing argument: database.' if !config[:database] if config[:host].nil? || config[:host] =~ /localhost/i config[:database] = File.(config[:database], defined?(Rails) && Rails.root) end config[:database] = "#{config[:host]}/#{config[:port]}:#{config[:database]}" if config[:host] config end |