Ruby 使用模块扩展cucumber并访问前/后挂钩

Ruby 使用模块扩展cucumber并访问前/后挂钩,ruby,cucumber,Ruby,Cucumber,我正在尝试编写一个通用模块来扩展世界级。我需要从模块内访问前后挂钩。我通过使用扩展方法来实现这一点,但此时似乎没有Before/After module MyWorld def MyWorld.extended(obj) obj.Before do # this doesn't work end end end 是否有其他方法访问这些挂钩?了解如何访问这些挂钩: module MyWorld def MyWorld.extended(obj) M

我正在尝试编写一个通用模块来扩展世界级。我需要从模块内访问前后挂钩。我通过使用扩展方法来实现这一点,但此时似乎没有Before/After

module MyWorld
  def MyWorld.extended(obj)
    obj.Before do
      # this doesn't work
    end
  end
end

是否有其他方法访问这些挂钩?

了解如何访问这些挂钩:

module MyWorld
  def MyWorld.extended(obj)
    Main.Before do
      # some stuff
    end

    Main.After do
      # some other stuff
    end   
  end
end

了解如何做到这一点:

module MyWorld
  def MyWorld.extended(obj)
    Main.Before do
      # some stuff
    end

    Main.After do
      # some other stuff
    end   
  end
end