Array#optionize!

class Array
  def optionize!(defaults={})
    defaults.merge(last.is_a?(Hash) ? pop : {})
  end
end
 
# meanwhile...
 
def masticate(*args)
  options = args.optionize!(:default => :value)
  # ...
end

About this entry