require 'facets/more/functor'
require 'facets/core/symbol/chomp'

class Proc

  # Build a hash out of a Proc.
  #
  #   l = lambda { |s|
  #     s.a = 1
  #     s.b = 2
  #     s.c = 3
  #   }
  #   l.to_h  #=> {:a=>1, :b=>2, :c=>3}
  #

  def to_h
    h = {}
    f = Functor.new{ |op, arg| h[op.chomp('=')] = arg }
    call( f )
    h
  end

end



# TODO Write test for Proc#to_h.