I am working on a small gem and I need kind of a direct access to
symbols table. Specifically, I would like to test whether particular
Symbol is already present in the table.
Using inline gem, when I refer to global_symbols directly, naturally I
get error:
/home/jrusnack/workspace/safe-intern/lib/safe-intern/exception_patch.rb:9:
error: ‘global_symbols’ undeclared (first use in this function)
The only two functions that call st_lookup(global_symbols,..) are
rb_intern3 and rb_id2str - I don`t see how to use either of them to
query the global_symbols without defining new symbol.
I am working on a small gem and I need kind of a direct access to
symbols table. Specifically, I would like to test whether particular
Symbol is already present in the table.
Symbol.find just appeared in ruby-trunk and will be in the 2.2.0 release
(December?)
Is there any workaround for this ?
You can backport r45175 from trunk to your version of Ruby.
Otherwise, you can try using Symbol.all_symbols (possibly caching the
output) to check.