Class: WePredict::User
Constant Summary collapse
- @@methods_and_required_params =
{:create => [:email, :password], :get => [:email, :password], :new_api_key => [:email, :password], :change_password => [:email, :password, :new_password], :change_email => [:email, :password, :new_email], :delete => [:email, :password], :forgotten_password => [:email], :reset_forgotten_password => [:email, :forgotten_password_code, :new_password]}
Class Method Summary collapse
-
.method_missing(method_name, *args, &block) ⇒ Object
Implements method calles for all the methods defined in @@methods_and_required_params which is intuitively a map of method names to their required paramaters.
-
.respond_to?(method_name) ⇒ Boolean
Implements correct respond_to? behaviour for methods defined through method_missing.
Methods inherited from API
Class Method Details
.method_missing(method_name, *args, &block) ⇒ Object
Implements method calles for all the methods defined in @@methods_and_required_params which is intuitively a map of method names to their required paramaters.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/wepredict/user.rb', line 18 def self.method_missing(method_name, *args, &block) if(respond_to?(method_name)) params?(args[0], @@methods_and_required_params[method_name]) method_name = "#{class_name.downcase}/#{method_name}" make_request(method_name, *args) else super end end |
.respond_to?(method_name) ⇒ Boolean
Implements correct respond_to? behaviour for methods defined through method_missing
32 33 34 |
# File 'lib/wepredict/user.rb', line 32 def self.respond_to?(method_name) !!@@methods_and_required_params[method_name] || super end |