require "pluck_to_hash/version"

module PluckToHash
  extend ActiveSupport::Concern

  module ClassMethods
    def pluck_to_hash(keys)
      pluck(*keys).map{|row| Hash[*[Array(keys), Array(row)].transpose.flatten]}
    end

    alias_method :pluck_h, :pluck_to_hash
  end
end

ActiveRecord::Base.send(:include, PluckToHash)

require "pluck_to_hash/version"

module PluckToHash
  extend ActiveSupport::Concern

  module ClassMethods
    def pluck_to_hash(keys)
      pluck(*keys).map{|row| Hash[Array(keys).zip(Array(row))]}
    end

    alias_method :pluck_h, :pluck_to_hash
  end
end

ActiveRecord::Base.send(:include, PluckToHash)

Fix bug when we ask for a single column and nil is one of the returned values
Fix bug when we ask for a single column and nil is one of the returned values
