class Hash def assert_valid_keys(*valid_keys) # Lifted from activesupport unknown_keys = keys - [valid_keys].flatten raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}") unless unknown_keys.empty? end def symbolize_keys! # Lifted from merb each do |key, value| sym = key.respond_to?(:to_sym) ? key.to_sym : key self[sym] = value delete(key) unless key == sym end self end end class Array def assert_valid_elements(*valid_elements) # Lifted from activesupport unknown_elements = self - [valid_elements].flatten raise(ArgumentError, "Unknown elements(s): #{unknown_elements.join(", ")}") unless unknown_elements.empty? end def symbolize_elements! collect! do |element| element.respond_to?(:to_sym) ? element.to_sym : element end self end end