Class: PcQueues::QueueRules::NumericQueueRule
- Inherits:
-
PcQueues::QueueRule
- Object
- ActiveRecord::Base
- PcQueues::QueueRule
- PcQueues::QueueRules::NumericQueueRule
- Defined in:
- lib/pc_queues/queue_rules/numeric_queue_rule.rb
Overview
A NumericQueueRule is a QueueRule that returns true when comparing the value to the numeric_value using an operator stored as a string.
These operators must be one of: <, >, ==, >=, <=
Class Method Summary collapse
Instance Method Summary collapse
- #operator ⇒ Object
- #passes?(obj, *args) ⇒ Boolean
-
#value(obj, *args) ⇒ Object
Implementors must provide an implementation of this method that takes the args splat passed to the queue and returns a numberic value.
Methods inherited from PcQueues::QueueRule
Class Method Details
.options(opts = {}) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/pc_queues/queue_rules/numeric_queue_rule.rb', line 19 def self.(opts = {}) opts[:numeric_value] ||= opts[:value] opts[:string_value] ||= opts[:operator] opts.except! :operator, :value super end |
Instance Method Details
#operator ⇒ Object
26 27 28 |
# File 'lib/pc_queues/queue_rules/numeric_queue_rule.rb', line 26 def operator string_value end |
#passes?(obj, *args) ⇒ Boolean
36 37 38 |
# File 'lib/pc_queues/queue_rules/numeric_queue_rule.rb', line 36 def passes?(obj, *args) value(obj, *args).send(operator, numeric_value) end |
#value(obj, *args) ⇒ Object
Implementors must provide an implementation of this method that takes the args splat passed to the queue and returns a numberic value
32 33 34 |
# File 'lib/pc_queues/queue_rules/numeric_queue_rule.rb', line 32 def value(obj, *args) raise NotImplementedError, "The class: #{self.class.name} requires an implementation of #{__method__}" end |