views:

71

answers:

2

we have understood the concept of fluent api but now we want to look over some existing fluent api for better understanding. where can i find such examples. have searched alot but could not find it.

A: 

May I suggest rspec? Here are a few lines from different real-world rspec specifications:

SQL.should_receive(:connect).with(config).and_return(connection1)
file_warehouse.should_receive(:delete).ordered.once.with(@keystring, paths)
arguments.should_receive(:config).with(no_args).any_number_of_times.and_return(config_path)
Wayne Conrad
+1  A: 

Arel is pretty awesome:

users.where(users[:name].eq('bob').or(users[:age].lt(25)))
comments.join(replies).on(replies[:parent_id].eq(comments[:id]))
Miguel Fonseca
hey thnks..v unerstood this piece of code but we want to see the working of itbut v cannot run this code as the actual methods are not defined..can u give us some more examples so tht v can run them and see the results also
intern
arel is part of ruby on rails 3, try installing it and give it a shot
Miguel Fonseca