Class: Module

Inherits:
Object show all
Defined in:
opal/stdlib/minitest/spec.rb,
opal/stdlib/native.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#infect_an_assertion(meth, new_name, dont_flip = false) ⇒ Object

:nodoc:



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'opal/stdlib/minitest/spec.rb', line 4

def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
  # warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
  dont_flip = !!dont_flip
  self.class_eval do
    define_method(new_name) do |*args|
      case
      when dont_flip
        Minitest::Spec.current.send(meth, self, *args)
      when Proc === self
        Minitest::Spec.current.send(meth, *args, &self)
      else
        Minitest::Spec.current.send(meth, args.first, self, *args[1..-1])
      end
    end
  end

  # <<-EOM
  #   def #{new_name} *args
  #     case
  #     when #{dont_flip} then
  #       Minitest::Spec.current.#{meth}(self, *args)
  #     when Proc === self then
  #       Minitest::Spec.current.#{meth}(*args, &self)
  #     else
  #       Minitest::Spec.current.#{meth}(args.first, self, *args[1..-1])
  #     end
  #   end
  # EOM
end

#native_moduleObject



535
536
537
# File 'opal/stdlib/native.rb', line 535

def native_module
  `Opal.global[#{self.name}] = #{self}`
end