Module: CASServer::CoreExt::String::ClassMethods
- Defined in:
- lib/casserver/core_ext/string.rb
Instance Method Summary collapse
-
#random(length = 29) ⇒ Object
if we’re on ruby 1.9 we’ll use the built in version this will break if someone trys to use ActiveSupport 3.2+ with Ruby 1.8.
Instance Method Details
#random(length = 29) ⇒ Object
if we’re on ruby 1.9 we’ll use the built in version this will break if someone trys to use ActiveSupport 3.2+ with Ruby 1.8
14 15 16 17 18 |
# File 'lib/casserver/core_ext/string.rb', line 14 def random(length = 29) str = "#{Time.now.to_i}r#{SecureRandom.urlsafe_base64(length)}" str.gsub!('_','-') str[0..(length - 1)] end |