ruby: two ways to implement before after