Class: GithubDeprecations::Config

Inherits:
Hashie::Dash
  • Object
show all
Defined in:
lib/github_deprecations.rb

Overview

add Dash#verify! so that it’s not checked on initialization

Instance Method Summary collapse

Instance Method Details

#register!Object

Register to intercept deprecation warnings.

For each deprecation, enqueue a background job to create or update an issue.



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/github_deprecations.rb', line 37

def register!
  @original_behavior = ActiveSupport::Deprecation.behavior
  ActiveSupport::Deprecation.behavior = :notify
  @subscriber = ActiveSupport::Notifications.subscribe(@subscribe) do |*args|
    begin
      Resque.enqueue Worker, self, args
    rescue Errno::ECONNREFUSED => e
      # unable to connect to redis, revert to default behavior
      $stderr.puts "WARNING: Unable to connect to redis for GithubDeprecations"
      reset!
    end
  end
end

#reset!Object



51
52
53
54
# File 'lib/github_deprecations.rb', line 51

def reset!
  ActiveSupport::Deprecation.behavior = @original_behavior if @original_behavior
  ActiveSupport::Notifications.unsubscribe(@subscriber) if @subscriber
end