Class: QBWC::ActiveRecord::Session
- Defined in:
- lib/qbwc/active_record/session.rb
Defined Under Namespace
Classes: QbwcSession
Instance Attribute Summary
Attributes inherited from Session
#company, #error, #progress, #status_code, #status_severity, #ticket, #user
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(session_or_user = nil, company = nil, ticket = nil) ⇒ Session
constructor
A new instance of Session.
- #save ⇒ Object
Methods inherited from Session
#began_at, #current_request, #error_and_stop_requested?, #finished?, #key, #next_request, #request_to_send, #response=, #response_is_error?
Constructor Details
#initialize(session_or_user = nil, company = nil, ticket = nil) ⇒ Session
Returns a new instance of Session.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/qbwc/active_record/session.rb', line 11 def initialize(session_or_user = nil, company = nil, ticket = nil) if session_or_user.is_a? QbwcSession @session = session_or_user # Restore current job from saved one on QbwcSession @current_job = QBWC.get_job(@session.current_job) if @session.current_job # Restore pending jobs from saved list on QbwcSession @pending_jobs = @session.pending_jobs.split(',').map { |job_name| QBWC.get_job(job_name) }.select { |job| ! job.nil? } super(@session.user, @session.company, @session.ticket) else super @session = QbwcSession.new @session.user = self.user @session.company = self.company @session.ticket = self.ticket self.save @session end end |
Class Method Details
.get(ticket) ⇒ Object
6 7 8 9 |
# File 'lib/qbwc/active_record/session.rb', line 6 def self.get(ticket) session = QbwcSession.find_by_ticket(ticket) self.new(session) if session end |
Instance Method Details
#destroy ⇒ Object
37 38 39 40 |
# File 'lib/qbwc/active_record/session.rb', line 37 def destroy @session.destroy super end |
#save ⇒ Object
30 31 32 33 34 35 |
# File 'lib/qbwc/active_record/session.rb', line 30 def save @session.pending_jobs = pending_jobs.map(&:name).join(',') @session.current_job = current_job.try(:name) @session.save super end |