Class: Elastix::Base
- Inherits:
-
Object
- Object
- Elastix::Base
- Defined in:
- lib/elastix/base.rb
Direct Known Subclasses
Class Method Summary collapse
- .close_db_connection ⇒ Object
- .establish_connection(web_options = {}, db_options = {}) ⇒ Object
- .establish_db_connection(host, username, password) ⇒ Object
- .establish_web_connection(host, username, password) ⇒ Object
- .reload ⇒ Object
- .web_connected? ⇒ Boolean
Class Method Details
.close_db_connection ⇒ Object
27 28 29 |
# File 'lib/elastix/base.rb', line 27 def self.close_db_connection ActiveRecord::Base.connection.close end |
.establish_connection(web_options = {}, db_options = {}) ⇒ Object
22 23 24 25 |
# File 'lib/elastix/base.rb', line 22 def self.establish_connection(={}, ={}) establish_web_connection([:host], [:username], [:password]) establish_db_connection([:host], [:username], [:password]) end |
.establish_db_connection(host, username, password) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/elastix/base.rb', line 12 def self.establish_db_connection(host, username, password) ActiveRecord::Base.establish_connection( :adapter => "mysql2", :host => host, :database => "asterisk", :username => username, :password => password, ) end |
.establish_web_connection(host, username, password) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/elastix/base.rb', line 4 def self.establish_web_connection host, username, password @@elastix = Mechanize.new @@elastix.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE @@base_address = "https://#{host}" login username, password end |
.reload ⇒ Object
40 41 42 |
# File 'lib/elastix/base.rb', line 40 def self.reload @@elastix.get("#{@@base_address}/config.php?handler=reload") end |
.web_connected? ⇒ Boolean
36 37 38 |
# File 'lib/elastix/base.rb', line 36 def self.web_connected? @@elastix.current_page.title != "Elastix - Login page" end |