Module: DBQ::BasicQueue

Defined in:
lib/dbq/basic_queue.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



3
4
5
6
# File 'lib/dbq/basic_queue.rb', line 3

def self.included(receiver)
  receiver.after_rollback :check_in!
  receiver.extend ClassMethods
end

Instance Method Details

#check_in!Object



34
35
36
37
# File 'lib/dbq/basic_queue.rb', line 34

def check_in!
  # necessary if we were frozen by a rolled back destroy call
  self.class.update(id, checked_out_at: nil)
end

#check_out!Object



30
31
32
# File 'lib/dbq/basic_queue.rb', line 30

def check_out!
  self.update_attributes(checked_out_at: Time.now)
end

#dataObject



44
45
46
# File 'lib/dbq/basic_queue.rb', line 44

def data
  wrapped_data['data'] if wrapped_data
end

#data=(new_data) ⇒ Object



39
40
41
42
# File 'lib/dbq/basic_queue.rb', line 39

def data=(new_data)
  self.wrapped_data ||= {}
  wrapped_data['data'] = new_data
end