You can use define_method
to remain at the same scope:
{'SomeName'=> 'some_address', 'SomeOtherName' => 'some_other_address'}.each do |name, the_address|
klass = Class.new() do
define_method(:address) do
the_address
end
end
Object.const_set(name, klass)
end
SomeName.new.address
# => "some_address"