I'm fairly sure that's a useless title... sorry.
I want to be able to pass in a Class to a method, and then use that class. Here's an easy, working, example:
def my_method(klass)
klass.new
end
Using that:
>> my_method(Product)
=> #<Product id:nil, created_at: nil, updated_at: nil, price: nil>
>> my_method(Order)
=> #<Order id:nil, created_at: nil, updated_at: nil, total_value: nil>
What doesn't work is trying to use the klass
variable on a module:
>> ShopifyAPI::klass.first
=> NoMethodError: undefined method `klass' for ShopifyAPI:Module
Am I attempting an impossible task? Can anyone shed some light on this?
Cheers