If you're on ruby 2.0 you can use keyword arguments.
If you're on older ruby, you can use hash opts parameter.
def self.make_sandwich(opts = {:bread => Bread,
:butter => Butter,
:cheese => Cheese})
bread_to_use = opts[:bread]
end
make_sandwich(:bread => some_bread,
:cheese => some_cheese)
Alternatively, you can set default values in the method's body and then just pass nil
in the method call.
def self.make_sandwich(bread = nil, butter = nil, cheese = nil)
bread ||= Bread
butter ||= Butter
cheese ||= Cheese
...
end
make_sandwich(bread, nil, cheese)