Stage implementation in Ruby