I'm trying to override a class method in a module that has been provided by a third party.
My goal is to check for the second argument, if it's a Hash then instantiate a new custom object, otherwise call the original implementation:
module ThirdParty def self.login(email, password_or_options) if password_or_options.is_a?(Hash) SafeSession.new(email, password_or_options['sid'], password_or_options['master_key'], password_or_options['shared_keys'], password_or_options['rsa_privk']).storage else super(email, password_or_options) end end Original method signature:
module ThirdParty def self.login(email, password) # Library doing its own stuff end end At the moment this is failing with
ThirdParty.login('email', { test: true }) NoMethodError: super: no superclass method `login' for ThirdParty:Module I'm also using ActiveSupport, in case there's a solution to this problem in this framework.