Class: PcQueues::QueueRule

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/pc_queues/queue_rule.rb

Overview

QueueRule is the base class (STI) for Rules that are evaluated as part of a QueueRuleSet There must be at least one implmentor of the passes? method in the hierachy of QueueRule being stored in a QueueRuleSet.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.accessible_attributesObject

attr_accessible :numeric_value, :string_value, :bool_value, :type



12
13
14
# File 'lib/pc_queues/queue_rule.rb', line 12

def self.accessible_attributes
  [:numeric_value, :string_value, :bool_value, :type]
end

.options(opts = {}) ⇒ Object

A convenience method for creating QueueRule instances with more declaritive code. Derived classes can implement and super to this.

Eg. rule_set.queue_rules.create(MyNewRule.options special_opt1: value)



22
23
24
25
# File 'lib/pc_queues/queue_rule.rb', line 22

def self.options(opts = {})
  opts[:type] = self.name
  opts
end

Instance Method Details

#passes?(enqueable, *args) ⇒ Boolean

All derived classes must implement this method and it must return a Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/pc_queues/queue_rule.rb', line 28

def passes?(enqueable, *args)
  raise NotImplementedError, "The class: #{self.class.name} requires an implementation of #{__method__}"
end