Sha256: 842c50469994a758b3f86daea6285533d0e9ca31c97759c761f8745989203d1d

Contents?: true

Size: 646 Bytes

Versions: 7

Compression:

Stored size: 646 Bytes

Contents

# frozen_string_literal: true
require 'opal/nodes/def'

module Opal
  module Nodes
    class DefsNode < DefNode
      handle :defs
      children :recvr, :mid, :args, :stmts

      def extract_block_arg
        *regular_args, last_arg = args.children
        if last_arg && last_arg.type == :blockarg
          @block_arg = last_arg.children[0]
          @sexp = @sexp.updated(nil, [
            recvr,
            mid,
            s(:args, *regular_args),
            stmts
          ])
        end
      end

      def wrap_with_definition
        unshift "Opal.defs(", expr(recvr), ", '$#{mid}', "
        push ")"
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
opal-0.11.4 lib/opal/nodes/defs.rb
opal-0.11.3 lib/opal/nodes/defs.rb
opal-0.11.2 lib/opal/nodes/defs.rb
opal-0.11.1 lib/opal/nodes/defs.rb
opal-0.11.1.pre lib/opal/nodes/defs.rb
opal-0.11.0 lib/opal/nodes/defs.rb
opal-0.11.0.rc1 lib/opal/nodes/defs.rb