Class: Promiscuous::Subscriber::Worker::EventualDestroyer::PendingDestroy
- Inherits:
-
Object
- Object
- Promiscuous::Subscriber::Worker::EventualDestroyer::PendingDestroy
- Defined in:
- lib/promiscuous/subscriber/worker/eventual_destroyer.rb
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#instance_id ⇒ Object
Returns the value of attribute instance_id.
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(raw) ⇒ PendingDestroy
constructor
A new instance of PendingDestroy.
- #perform ⇒ Object
Constructor Details
#initialize(raw) ⇒ PendingDestroy
Returns a new instance of PendingDestroy.
49 50 51 52 53 54 55 |
# File 'lib/promiscuous/subscriber/worker/eventual_destroyer.rb', line 49 def initialize(raw) params = MultiJson.load(raw).with_indifferent_access @class_name = params[:class_name] @instance_id = params[:instance_id] @raw = raw end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
33 34 35 |
# File 'lib/promiscuous/subscriber/worker/eventual_destroyer.rb', line 33 def class_name @class_name end |
#instance_id ⇒ Object
Returns the value of attribute instance_id.
33 34 35 |
# File 'lib/promiscuous/subscriber/worker/eventual_destroyer.rb', line 33 def instance_id @instance_id end |
Class Method Details
.count ⇒ Object
67 68 69 |
# File 'lib/promiscuous/subscriber/worker/eventual_destroyer.rb', line 67 def self.count redis.zcard(key) end |
.create(options) ⇒ Object
63 64 65 |
# File 'lib/promiscuous/subscriber/worker/eventual_destroyer.rb', line 63 def self.create() redis.zadd(key, Time.now.utc.to_i, .to_json) end |
.next(timeout) ⇒ Object
57 58 59 60 61 |
# File 'lib/promiscuous/subscriber/worker/eventual_destroyer.rb', line 57 def self.next(timeout) redis.zrangebyscore(key, 0, timeout.ago.utc.to_i).map do |raw| self.new(raw) end end |
Instance Method Details
#destroy ⇒ Object
45 46 47 |
# File 'lib/promiscuous/subscriber/worker/eventual_destroyer.rb', line 45 def destroy self.class.redis.zrem(self.class.key, @raw) end |
#perform ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/promiscuous/subscriber/worker/eventual_destroyer.rb', line 35 def perform model = class_name.constantize begin model.__promiscuous_fetch_existing(instance_id).destroy rescue model.__promiscuous_missing_record_exception end self.destroy end |