Class: Qs::Job

Inherits:
Message show all
Defined in:
lib/qs/job.rb

Direct Known Subclasses

DispatchJob

Constant Summary collapse

PAYLOAD_TYPE =
'job'

Instance Attribute Summary collapse

Attributes inherited from Message

#params, #payload_type

Instance Method Summary collapse

Methods inherited from Message

#route_id

Constructor Details

#initialize(name, options = nil) ⇒ Job

Returns a new instance of Job.



11
12
13
14
15
16
17
18
# File 'lib/qs/job.rb', line 11

def initialize(name, options = nil)
  options ||= {}
  options[:params] ||= {}
  validate!(name, options[:params])
  @name       = name
  @created_at = options[:created_at] || Time.now
  super(PAYLOAD_TYPE, options)
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



9
10
11
# File 'lib/qs/job.rb', line 9

def created_at
  @created_at
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/qs/job.rb', line 9

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/qs/job.rb', line 32

def ==(other)
  if other.kind_of?(self.class)
    self.payload_type == other.payload_type &&
    self.name         == other.name         &&
    self.params       == other.params       &&
    self.created_at   == other.created_at
  else
    super
  end
end

#inspectObject



24
25
26
27
28
29
30
# File 'lib/qs/job.rb', line 24

def inspect
  reference = '0x0%x' % (self.object_id << 1)
  "#<#{self.class}:#{reference} " \
  "@name=#{self.name.inspect} " \
  "@params=#{self.params.inspect} " \
  "@created_at=#{self.created_at.inspect}>"
end

#route_nameObject



20
21
22
# File 'lib/qs/job.rb', line 20

def route_name
  self.name
end