lib/flexmls_api/authentication/oauth2.rb in flexmls_api-0.7.0 vs lib/flexmls_api/authentication/oauth2.rb in flexmls_api-0.7.3

- old
+ new

@@ -168,9 +168,18 @@ require 'flexmls_api/authentication/oauth2_impl/grant_type_base' require 'flexmls_api/authentication/oauth2_impl/grant_type_refresh' require 'flexmls_api/authentication/oauth2_impl/grant_type_code' require 'flexmls_api/authentication/oauth2_impl/grant_type_password' require 'flexmls_api/authentication/oauth2_impl/password_provider' + + # Loads a provider class from a string + def self.load_provider(string, args={}) + constant = Object + string.split("::").compact.each { |name| constant = constant.const_get(name) unless name == ""} + constant.new(args) + rescue => e + raise ArgumentError, "The value '#{string}' is an invalid class name for an oauth2 provider: #{e.message}" + end end end end