toretore (owner)

Fork Of

Revisions

gist: 230087 Download_button fork
public
Public Clone URL: git://gist.github.com/230087.git
Embed All Files: show embed
want_a_closure.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  def build_conditions
    conditions = {}
    def condition(cond, &f)
      if block_given?
        conditions += yield(cond)
      else
        conditions += lambda {|c| {c => params{c}}}.call
      end
    end
    condition("address") do |addr|
      ["adddress like ?", addr]
    end
    conditions
  end