Class: MSF

Inherits:
Object
  • Object
show all
Defined in:
lib/msf/msf.rb

Overview

This class establishes an ActiveRecord connection to an MSF file (sqlite3 database) at the specified path.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ MSF

msf.connection.tables

msf.connection.disconnect!
msf.reconnect


22
23
24
25
26
27
# File 'lib/msf/msf.rb', line 22

def initialize(attributes={})
  attributes.each do |name, value|
    send("#{name}=", value)
  end
  @connection = ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => @path).connection
end

Instance Attribute Details

#connectionObject (readonly)

the resulting ActiveRecord::Base.connection



9
10
11
# File 'lib/msf/msf.rb', line 9

def connection
  @connection
end

#pathObject

filesystem PATH to an MSF file



7
8
9
# File 'lib/msf/msf.rb', line 7

def path
  @path
end

Instance Method Details

#reconnectObject

reconnect to the MSF file (sqlite3 database)



29
30
31
# File 'lib/msf/msf.rb', line 29

def reconnect
  @connection = ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => @path).connection
end