Class: Module

Inherits:
Object show all
Defined in:
lib/yoda.rb

Instance Method Summary collapse

Instance Method Details

#yodaObject



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/yoda.rb', line 50

def yoda
  public_instance_methods(false).each do |method|
    class_eval "
    alias :darth_#{method} :#{method}
    def #{method}(*args)
      if Yoda::Expectation === args.first then
        args.first.matches self.darth_#{method}
      else
        self.darth_#{method}(*args)
      end
    end"
  end

  yield
end