Class: Symbol

Inherits:
Object show all
Defined in:
lib/user_input.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_user_input(value) ⇒ Object

Raises:

  • (ArgumentError)


201
202
203
# File 'lib/user_input.rb', line 201

def Symbol.from_user_input(value)
	raise ArgumentError, "You should never arbitrarily turn user input into symbols. It can cause leaks that could lead to DoS."
end

Instance Method Details

#from_user_input(value) ⇒ Object

instance form does a straight comparison of value.to_sym with self.



206
207
208
209
210
211
212
# File 'lib/user_input.rb', line 206

def from_user_input(value)
	if (self.to_s == value.to_s)
		return self
	else
		return nil
	end
end