aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_relation/extensions/hash.rb
blob: a33ace573850b18e9d81cf458706910c92c05603 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
class Hash
  def bind(relation)
    descend { |x| x.bind(relation) }
  end
  
  def descend(&block)
    inject({}) do |descendent, (key, value)|
      descendent.merge(yield(key) => yield(value))
    end
  end
end