# File lib/facets/core/kernel/populate.rb, line 8 def populate( data=nil, &yld ) if data data.to_h.each do |k,v| send( "#{k}=", v ) rescue nil end end if yld yld.to_h.each do |k,v| send( "#{k}=", v ) rescue nil end end # If the context of the error could be known # this could be used instead of converting the # block to a hash. #begin # yield self #rescue NoMethodError => e # if e.context == self and e.name.to_s =~ /=$/ # resume # else # raise e # end #end self end