Class: NetMate::Connection
- Inherits:
-
Object
- Object
- NetMate::Connection
- Defined in:
- lib/net_mate/connection.rb
Instance Attribute Summary collapse
-
#db_config ⇒ Object
readonly
Returns the value of attribute db_config.
Class Method Summary collapse
Instance Method Summary collapse
- #connect ⇒ Object
-
#initialize(path = nil) ⇒ Connection
constructor
A new instance of Connection.
Constructor Details
#initialize(path = nil) ⇒ Connection
Returns a new instance of Connection.
9 10 11 12 13 14 |
# File 'lib/net_mate/connection.rb', line 9 def initialize path = nil path ||= "#{ROOT_PATH}/config/database.yml" @db_config = YAML.load_file(path)['development'] rescue abort 'Please check if you are in the proper Application directory!' end |
Instance Attribute Details
#db_config ⇒ Object (readonly)
Returns the value of attribute db_config.
8 9 10 |
# File 'lib/net_mate/connection.rb', line 8 def db_config @db_config end |
Class Method Details
.disconnect(dbh) ⇒ Object
20 21 22 |
# File 'lib/net_mate/connection.rb', line 20 def self.disconnect dbh dbh.close if dbh end |
Instance Method Details
#connect ⇒ Object
16 17 18 |
# File 'lib/net_mate/connection.rb', line 16 def connect Mysql2::Client.new @db_config end |