Module: Ruby2JS::Filter::SecureRandom

Extended by:
SEXP
Includes:
SEXP
Defined in:
lib/ruby2js/filter/securerandom.rb

Constant Summary collapse

IMPORT_BASE62_RANDOM =
s(:import, ['base62-random'],
s(:attr, nil, :base62_random))

Instance Method Summary collapse

Methods included from SEXP

S, s

Instance Method Details

#on_send(node) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/ruby2js/filter/securerandom.rb', line 15

def on_send(node)
  target, method, *args = node.children

  if target == s(:const, nil, :SecureRandom)
    if method == :alphanumeric and args.length == 1
      prepend_list << IMPORT_BASE62_RANDOM
      node.updated(nil, [nil, :base62_random, *args])
    else
      super
    end
  else
    super
  end
end