From: "midnight (Sarun R)" <noreply@...> Date: 2022-06-09T19:13:16+00:00 Subject: [ruby-core:108839] [Ruby master Feature#18183] make SecureRandom.choose public Issue #18183 has been updated by midnight (Sarun R). In case we really can't agree on the name. I reimplement the functionality as an independent class on a GitHub's Gist; without using non-public API and the `send` hack, of course. https://gist.github.com/midnight-wonderer/8fec1c670bd07f26b9466010842d2421 Usage: ~~~Ruby code_generator = RandomCode.new(choose_from: ('A'..'Z').to_a) code_generator.call(10) ~~~ It would be better if the functionality is in the core, though. ---------------------------------------- Feature #18183: make SecureRandom.choose public https://bugs.ruby-lang.org/issues/18183#change-97917 * Author: olleicua (Antha Auciello) * Status: Rejected * Priority: Normal ---------------------------------------- This issue https://bugs.ruby-lang.org/issues/10849 added `SecureRandom.alphanumeric` and also the private method choose. `choose` was kept private because the method name wasn't the best name to represent the behavior. I think if it was called `random_string` it would be very clear what it does. I also think it should be aliased to choose as well to allow backwards compatibility for people bypassing the private method with `send` (e.g. https://www.thetopsites.net/article/58611103.shtml) I'm planning to put together a pull request for this. Please let me know if there are any complications I'm not considering. -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>