Module: MergingQueue::Actor

Extended by:
ActiveSupport::Concern
Defined in:
lib/merging-queue/actor.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#publish_queued_task(name, cur_publish_on, options = {}) ⇒ Object

Publishes the queued_task to the receivers

Examples:

publish an queued_task with a act_object and act_target

current_user.publish_queued_task(:enquiry, :act_object => @enquiry, :act_target => @listing)

Parameters:

  • options (Hash) (defaults to: {})

    The options to publish with.



32
33
34
35
36
# File 'lib/merging-queue/actor.rb', line 32

def publish_queued_task(name, cur_publish_on, options={})
  cur_publish_on = Time.now + cur_publish_on if cur_publish_on.kind_of?(Fixnum)
  raise "Expected Time type. Got:" + cur_publish_on.class.name  unless cur_publish_on.kind_of?(Time)
  queued_task_class.publish(name, cur_publish_on, {:actor => self}.merge(options))
end

#queued_merging_tasks(options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/merging-queue/actor.rb', line 42

def queued_merging_tasks(options = {})

  if options.empty?
    queued_tasks
  else
    queued_tasks.where(options)
  end

end

#queued_task_classObject



38
39
40
# File 'lib/merging-queue/actor.rb', line 38

def queued_task_class
  @queued_task_klass ||= queued_task_klass ? queued_task_klass.classify.constantize : ::QueuedTask
end