Class: Ruote::Resque::ParticipantRegistrar

Inherits:
Object
  • Object
show all
Defined in:
lib/ruote/resque/participant_registrar.rb

Overview

An object to easy Participant registration

Examples:

Register a participant

# Will register a participant be_awesome
# that enqueues the Job MyAwesomeJob to my_queue
Ruote::Resque.register(dashboard) do
  be_awesome 'MyAwesomeJob', :my_queue
  # or via the participant method
  participant 'be_awesome', 'MyAwesomeJob', :my_queue
end

Instance Method Summary collapse

Constructor Details

#initialize(dashboard) ⇒ Ruote::Resque::ParticipantRegistrar

Parameters:

  • dashboard (Ruote::Dashboard)


19
20
21
# File 'lib/ruote/resque/participant_registrar.rb', line 19

def initialize(dashboard)
  @dashboard = dashboard
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object

Implements the dsl to register participants



25
26
27
# File 'lib/ruote/resque/participant_registrar.rb', line 25

def method_missing(method_name, *args, &block)
  participant(method_name.to_s, *args, &block)
end

Instance Method Details

#participant(name, klass, queue, options = {}) ⇒ void

This method returns an undefined value.

Call this method to register a participant (or use method_missing)

Parameters:

  • name (#to_s)

    the name of the participant

  • klass (#to_s)

    the class of the Resque job

  • queue (#to_s)

    the queue of the job

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

    options to be passed on to +Ruote::Resque::Participant+



35
36
37
38
# File 'lib/ruote/resque/participant_registrar.rb', line 35

def participant(name, klass, queue, options = {})
  options.merge!({ :class => klass, :queue => queue })
  @dashboard.register_participant(name, Ruote::Resque::Participant, options)
end