I’m using Rails 4.2.7 on Ubuntu 14.04. According to this — Why doesn't ruby support method overloading? , I should be able to overload methods in my service class if each method has a different number of arguments. So I have created …
def create_my_object_time_obj(data_hash)
create_my_object_time_obj(data_hash, nil)
end
def create_my_object_time_obj(data_hash, my_object_id)
…
Yet, when I try and invoke the call that only takes a single argument
my_object_time = service.create_my_object_time_obj(data_hash)
I get the error
Error during processing: wrong number of arguments (given 1, expected 2)
/Users/login/Documents/workspace/myproject/app/services/text_table_to_my_object_time_converter_service.rb:82:in `create_my_object_time_obj'
What’s the right way to overload my methods from my service class?