aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/extensions/hash.rb
blob: bc97785e62de7f37e7f4c49a7fc6d4889c534a18 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Hash
  def bind(relation)
    inject({}) do |bound, (key, value)|
      bound.merge(key.bind(relation) => value.bind(relation))
    end
  end
  
  def slice(*attributes)
    inject({}) do |cheese, (key, value)|
      cheese[key] = value if attributes.include?(key)
      cheese
    end
  end
end