class TwitterPublisher def publish(status) # ... end end class FacebookPublisher def publish(status) # ... end end status = Status.new status.publisher = TwitterPublisher.new status.publish
EmailNotifier < SimpleDelegator def publish super && notify! end private def notify! # ... end end post = Post.new notifiable_post = EmailNotifier.new(post) notifiable_post.publish