RE: Is this a good, secure way for generating classes in Ruby programming?

You are viewing a single comment's thread from:

Is this a good, secure way for generating classes in Ruby programming?

in ruby •  8 years ago 

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.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Hehe. I think your approach is much better than mine.
:)