Skip to content

Instantly share code, notes, and snippets.

@aalavandhan
Created September 19, 2014 19:55
Show Gist options
  • Save aalavandhan/741613afb440a94cf1c4 to your computer and use it in GitHub Desktop.
Save aalavandhan/741613afb440a94cf1c4 to your computer and use it in GitHub Desktop.
A simple implementation of Javascript With Operator in ruby,
class With
attr_accessor :object, :result
def initialize(object)
@object = object
@result = nil
end
def method_missing(method, *args, &block)
@result = @object.send(method, *args, &block)
self
end
end
def With(object)
With.new(object)
end
With(1).+(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment