Class: RCelery::Task::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/rcelery/task/context.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Context

Returns a new instance of Context.



4
5
6
# File 'lib/rcelery/task/context.rb', line 4

def initialize(name)
  @key = "#{name}.request"
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/rcelery/task/context.rb', line 16

def method_missing(method, *args)
  if args.length.zero?
    Thread.current[@key][method]
  else
    super(method, *args)
  end
end

Instance Method Details

#clearObject



12
13
14
# File 'lib/rcelery/task/context.rb', line 12

def clear
  update
end

#update(options = {}) ⇒ Object



8
9
10
# File 'lib/rcelery/task/context.rb', line 8

def update(options = {})
  Thread.current[@key] = options
end