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

in ruby •  8 years ago 


I wrote a dynamic class to allow the generation of dynamic classes in Ruby programming language.

I wonder if this is secure. PHP did not allow that, I think.

But Ruby seems to allow it. 

Here is the link:

Ruby Example Class to generate another class

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:  

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.
:)