Module: InvisionBridge

Defined in:
lib/invision_bridge.rb,
lib/invision_bridge/active_record.rb

Defined Under Namespace

Modules: ActiveRecord

Class Method Summary collapse

Class Method Details

.configObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/invision_bridge.rb', line 7

def self.config
  if @config.nil?
    if Rails
      config_file = File.join(Rails.root, 'config', 'database.yml')
      config_group = "invision_bridge_#{Rails.env}"
    else
      config_file = File.join(File.dirname(__FILE__), '..', '..', 'config', 'database.yml')
      config_group = "invision_bridge"
    end

    config = YAML::load(File.open(config_file))
    config = config[config_group]

    if config.nil?
      raise "** [InvisionBridge] Unable to read database configuration from #{config_file} -- Make sure an #{config_group} definition exists."
    else
      config['prefix'] ||= 'ibf_'
    end

    @config = config
  end

  @config
end

.included(base) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/invision_bridge.rb', line 32

def self.included(base)
  if base.respond_to? :establish_connection
    base.send(:include, InvisionBridge::ActiveRecord)
  else
    raise "** [InvisionBridge] Currently we only support ActiveRecord models. Sorry."
  end
end