Module: Ext::ActiveRecord::CClassMethods
- Defined in:
- lib/ext/active_record.rb
Overview
Class methods for you app
Instance Attribute Summary collapse
-
#database ⇒ Object
If set, #create will launch your database with those params.
-
#manager ⇒ Object
readonly
Set if #create initialized your database.
Instance Method Summary collapse
-
#create ⇒ Object
Tries to connect and create the databases.
Instance Attribute Details
#database ⇒ Object
If set, #create will launch your database with those params.
103 104 105 |
# File 'lib/ext/active_record.rb', line 103 def database @database end |
#manager ⇒ Object (readonly)
Set if #create initialized your database.
106 107 108 |
# File 'lib/ext/active_record.rb', line 106 def manager @manager end |
Instance Method Details
#create ⇒ Object
Tries to connect and create the databases.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/ext/active_record.rb', line 109 def create puts "INFO: ActiveRecord#create called" if $DBG if self.database and not @manager # Loads the adapter dynamically adapter = self.database[:adapter] || self.database['adapter'] unless adapter.nil? or RAILS_CONNECTION_ADAPTERS.include? adapter require "active_record/connection_adapters/" + adapter + "_adapter" RAILS_CONNECTION_ADAPTERS << adapter end @manager = self::Models::AllYourBase.establish_connection self.database puts "INFO: ActiveRecord connection established : #{@manager.inspect}" if $DBG case @logger when Logger self::Models::AllYourBase.logger = @logger when String self::Models::AllYourBase.logger = Logger.new(@logger == "-" ? STDOUT : @logger) else self::Models::AllYourBase.logger = Logger.new(STDOUT) end end # run check_create on models self::Models.constants.each do |c| if c != 'Base' c = self::Models.const_get(c) c.check_create if c.respond_to? :check_create end end super end |