Class: Extface::Device
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Extface::Device
- Defined in:
- app/models/extface/device.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#driver_class ⇒ Object
26 27 28 |
# File 'app/models/extface/device.rb', line 26 def driver_class driver.try(:class) end |
Instance Method Details
#driver_name ⇒ Object
30 31 32 |
# File 'app/models/extface/device.rb', line 30 def driver_name driver_class::NAME if driver_class end |
#session(description = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/extface/device.rb', line 34 def session(description = nil) job = jobs.create!(description: description) Thread.new do begin raise 'No driver configured' unless driver.present? if driver.set_job(job) yield driver job.complete! else raise driver.errors..join(', ') end rescue => e STDERR.puts e. e.backtrace.each do |line| p line end job.failed! e. ensure ActiveRecord::Base.connection.close end end job end |