class T1 end arr = {:a=>1, :b=>2} arr.each do |k, v| T1.class_eval "def self.#{k.to_s}\n #{v}\n end" end puts T1.a