Class: Wamp::Worker::Queue::Descriptor
- Inherits:
-
Object
- Object
- Wamp::Worker::Queue::Descriptor
- Defined in:
- lib/wamp/worker/queue.rb
Overview
This class represents the payload that will be stored in Redis
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Class Method Summary collapse
-
.from_json(json_string) ⇒ Descriptor
Create a Descriptor object from the json payload.
Instance Method Summary collapse
-
#initialize(command, handle, params) ⇒ Descriptor
constructor
Constructor.
-
#to_json ⇒ String
Creates the json payload from the object.
Constructor Details
#initialize(command, handle, params) ⇒ Descriptor
Constructor
18 19 20 21 22 |
# File 'lib/wamp/worker/queue.rb', line 18 def initialize(command, handle, params) @command = command.to_sym @handle = handle @params = params || {} end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
11 12 13 |
# File 'lib/wamp/worker/queue.rb', line 11 def command @command end |
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
11 12 13 |
# File 'lib/wamp/worker/queue.rb', line 11 def handle @handle end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
11 12 13 |
# File 'lib/wamp/worker/queue.rb', line 11 def params @params end |
Class Method Details
.from_json(json_string) ⇒ Descriptor
Create a Descriptor object from the json payload
28 29 30 31 32 |
# File 'lib/wamp/worker/queue.rb', line 28 def self.from_json(json_string) return unless json_string parsed = JSON.parse(json_string, :symbolize_names => true) self.new(parsed[:command], parsed[:handle], parsed[:params]) end |
Instance Method Details
#to_json ⇒ String
Creates the json payload from the object
37 38 39 |
# File 'lib/wamp/worker/queue.rb', line 37 def to_json { command: self.command, handle: self.handle, params: self.params }.to_json end |