Class: JobContracts::QueueNameContract
- Defined in:
- lib/job_contracts/contracts/queue_name_contract.rb
Instance Attribute Summary
Attributes inherited from Contract
Instance Method Summary collapse
- #enforce!(contractable) ⇒ Object
-
#initialize(queue_name:) ⇒ QueueNameContract
constructor
A new instance of QueueNameContract.
Methods inherited from Contract
#actual, #after?, #before?, #breached?, #expected, #halt?, #satisfied?, #should_enforce?, #to_h
Constructor Details
#initialize(queue_name:) ⇒ QueueNameContract
Returns a new instance of QueueNameContract.
7 8 9 10 11 12 13 14 |
# File 'lib/job_contracts/contracts/queue_name_contract.rb', line 7 def initialize(queue_name:) super( trigger: :before, halt: true, queues: ["*"], expected: {queue_name: queue_name.to_s} ) end |
Instance Method Details
#enforce!(contractable) ⇒ Object
16 17 18 19 20 |
# File 'lib/job_contracts/contracts/queue_name_contract.rb', line 16 def enforce!(contractable) actual[:queue_name] = contractable.queue_name.to_s self.satisfied = contractable.queue_name.to_s == expected[:queue_name] super end |