This is reasonably secure - at least, provided you aren't including user-provided data in your class definition - but it's also fairly pointless. Ruby is a highly dynamic and flexible language that allows you to define classes dynamically without writing them to separate files at all.
Skip creating new files - if you want a new class, you can just call Class.new
, like this:
class DynamicClass
Dynamic2Class = Class.new do
puts "Hello from the other side"
end
end
Of course, in reality you'd do something more useful with dynamically-generated classes, but this basic approach will work.
Hehe. I think your approach is much better than mine.
:)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit