I'm using HTTParty for my class, and I want to use the default_params method. However, I also want to be able to set attributes when instantiation my class with initialize.
class MyClass
include HTTParty
attr_accessor :param1, :param2
# This or @param1 doesn't work.
default_params :param1 => self.param1, :param2 => self.param2
def initialize(param1, param2)
self.param1 = param1
self.param2 = param2
end
end
This way I can do
m = MyClass.new('hey', 'hello')
instead of
m = MyClass.new
m.param1 = 'hey'
m.param2 = 'hello'
But I'd like to use the attributes with default_params. How can I do this?