Tried to implement the feature just like AngularJS Promises in Ruby