# # Copyright (C) 2013-2015 Globo.com # # This file is part of TDI. # TDI is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # TDI is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with TDI. If not, see . module HashRecursiveBlank def rblank r = {} each_pair do |key, val| r[key] = val.rblank if val.is_a?(Hash) end r.keep_if { |key, val| val.is_a?(Hash) } end def rblank! each_pair do |key, val| self[key] = val.rblank! if val.is_a?(Hash) end keep_if { |key, val| val.is_a?(Hash) } end end class Hash include HashRecursiveBlank end