Skip to content

Commit

Permalink
Monkey patch oauth-plugin to avoid using deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Jun 11, 2017
1 parent 6183def commit 9b793b8
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions config/initializers/oauth.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require "oauth/controllers/provider_controller"
require "oauth/rack/oauth_filter"

Rails.configuration.middleware.use OAuth::Rack::OAuthFilter
Expand All @@ -11,3 +12,41 @@ def method
end
end
end

module OpenStreetMap
module ProviderController
def self.prepended(mod)
mod.singleton_class.prepend(OpenStreetMap::ProviderController::ClassMethods)
end

def render(options = {})
text = options.delete(:text)
if text
super options.merge(:plain => text)
elsif options.delete(:nothing)
status = options.delete(:status) || :ok
head status, options
else
super options
end
end

module ClassMethods
def included(controller)
controller.class_eval do
def self.before_filter(*names, &blk)
before_action(*names, &blk)
end

def self.skip_before_filter(*names, &blk)
skip_before_action(*names, &blk)
end
end

super controller
end
end
end
end

OAuth::Controllers::ProviderController.prepend(OpenStreetMap::ProviderController)

0 comments on commit 9b793b8

Please sign in to comment.