Module: ResqueBus::Deprecated

Included in:
ResqueBus
Defined in:
lib/resque_bus/compatibility/deprecated.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



33
34
35
36
# File 'lib/resque_bus/compatibility/deprecated.rb', line 33

def method_missing(method_name, *args, &block)
  ResqueBus.note_deprecation "[DEPRECATION] ResqueBus direct usage is deprecated. Use `QueueBus.#{method_name}` instead."
  ::QueueBus.send(method_name, *args, &block)
end

Instance Method Details

#note_deprecation(message) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/resque_bus/compatibility/deprecated.rb', line 14

def note_deprecation(message)
  @noted_deprecations ||= {}
  if @noted_deprecations[message]
    @noted_deprecations[message] += 1
  else
    warn(message) if show_deprecations?
    @noted_deprecations[message] = 1
  end
end

#redisObject



24
25
26
27
# File 'lib/resque_bus/compatibility/deprecated.rb', line 24

def redis
  ResqueBus.note_deprecation "[DEPRECATION] ResqueBus direct usage is deprecated. Use `QueueBus.redis` instead. Note that it also requires block usage now."
  ::Resque.redis
end

#redis=(val) ⇒ Object



29
30
31
# File 'lib/resque_bus/compatibility/deprecated.rb', line 29

def redis=val
  ResqueBus.note_deprecation "[DEPRECATION] ResqueBus can no longer set redis directly. It will use Resque's instance of redis."
end

#show_deprecations=(val) ⇒ Object



3
4
5
# File 'lib/resque_bus/compatibility/deprecated.rb', line 3

def show_deprecations=val
  @show_deprecations = val
end

#show_deprecations?Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
# File 'lib/resque_bus/compatibility/deprecated.rb', line 7

def show_deprecations?
  return @show_deprecations if defined?(@show_deprecations)
  return true if !ENV['QUEUES'] && !ENV['QUEUE'] # not in background, probably test
  return true if ENV['VVERBOSE'] || ENV['LOGGING'] || ENV['VERBOSE']
  false
end