Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

chaining example

View gist:3332095
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
class Search
class << self
def where(args)
Search.new(args)
end
end
def initialize(args)
@search_arguments = args
end
def where(args)
@search_arguments.merge!(args)
self
end
def each
results.each{|a| yield(a)}
end
def results
#Go and get some results!
end
end
 
#irb(main):084:0> Search.where(:foo => 'bar').where(:magic_number => 3)
#=> #<Search:0x10aa5e9d8 @search_arguments={:foo=>"bar", :magic_number=>3}>
 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.