Adam Carlile
Meta programming, serialization

Oh wow, has it been that long already, I need to force myself to post something at least once a week, even if it’s just posting pictures of cats!

So I’m currently working on a social media platform for London, with it’s main purpose being to promote a wellbeing lifestyle in a hectic city. I wrote this handy little utility module for creating methods from serialized data.

Say, for example you have an object, but it can have serialized data stored within a hash in the database, instead of getting the data through the hash notation, you can now access it directly as Object.first.hash_key_name instead of Object.first.hash[:hash_key_name]

This is handy in two ways, you can access serialized data directly as methods of the class instance. Plus you can use the serialized fields directly in a form, as the module automatically creates the setters for the hashes keys. Pretty handy, you just have to specify in an array of serialized field symbols as a private method in the parent class.

Thousands of sites have been hit over the weekend with a series of SQL injection attacks. This may well be a flaw in MSSQL but it’s still a poignant reminder to ensure that you sanitise all user input, as malicious users can still try to exploit your database