Move logic out of ruby_js/todos.rb and generalize