Class: Lamed::DM
Overview
Support for DataMapper
Instance Method Summary collapse
- #connect(params = {}) ⇒ Object
-
#initialize(params = {}) ⇒ DM
constructor
Setup the database connection using DataMapper.
Constructor Details
#initialize(params = {}) ⇒ DM
Setup the database connection using DataMapper
23 24 25 26 27 28 29 30 31 |
# File 'lib/lamed/model.rb', line 23 def initialize(params = {}) @host = params[:host] || 'localhost' @port = (params[:port] || 3306).to_i @user = params[:username] || 'root' @password = params[:password] || 'pwd' @database = params[:database] || 'ithingy' @adapter = params[:adapter] || 'mysql' self.connect end |
Instance Method Details
#connect(params = {}) ⇒ Object
33 34 35 |
# File 'lib/lamed/model.rb', line 33 def connect(params = {}) DataMapper.setup(:default, "#{@adapter}://#{@user}:#{@password}@#{@host}:#{@port}/#{@database}") end |