Class: AllQ::Put

Inherits:
Base
  • Object
show all
Defined in:
lib/allq/actions/put.rb

Constant Summary

Constants inherited from Base

Base::ALLQ_DEBUG_DATA

Instance Attribute Summary

Attributes inherited from Base

#client, #connection

Instance Method Summary collapse

Methods inherited from Base

#build_job, #initialize, #rcv, #send_hash_as_json, #setup

Constructor Details

This class inherits a constructor from AllQ::Base

Instance Method Details

#base_send(tube, body, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/allq/actions/put.rb', line 15

def base_send(tube, body, options = {})
  raise 'Must have tube name and body' unless tube && body
  base = {
    'action' => 'put',
    'params' => {
      'tube' => tube,
      'body' => body
    }
  }
  base['params']['ttl'] = options['ttl'] if options['ttl']
  base['params']['delay'] = options['delay'] if options['delay']
  base['params']['parent_id'] = options['parent_id'] if options['parent_id']
  base['params']['priority'] = options['priority'] if options['priority']
  return base
end

#snd(data) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/allq/actions/put.rb', line 4

def snd(data)
  result = nil
  tube = data.delete('tube')
  body = data.delete('body')

  send_data = base_send(tube, body, data)
  response = send_hash_as_json(send_data)
  result = rcv(response)
  build_job(result)
end