News for hackers. Stuff that matters.
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by kjbekkelund on Tuesday August 03, 2010 @06:38PM (#1573006)
What about doing it like this in Ruby:

    collection = Braintree::Transaction.search do
      order_id /^a2d/
      customer_website /\.com$/
      billing_first_name "John"
      status :authorized, :settled
      amount 10..20
    end
    
    collection.each do
      puts id
    end
It might be more difficult not having the specific methods (in, starts_with_ ends_with, and so on), but I think it's quite readable. If we don't want the regexps, we could go for a MySQL style '%.com' and 'a2d%' or something similar.
Re:A DSL in 5 Languages: Ruby, Python, PHP, C#, Java by koenigdavidmj on Wednesday August 04, 2010 @02:21AM (#1573812)
They said above that they were turning the conditions into XML in the request. That's one of the reasons why C# expression trees were out.