So I don't have a model called Person, but I use hashes like {:name => "Siddharth", :sex => "Y"}. Great. Now I want to validate the presence of certain fields before persisting to the database. What do I do?
Module PersonValidation
function validate_presence_of_name(person_hash)
person_hash[:errors][:name] = "EEENKKK!" unless person_hash[:name]
end
...
...
end
So I must be missing something because how is this different from a class in a dynamic language? The above approach means you can easily swap out functions in one module for another and thus not tie the validation implementation to the structure of the loan hash, but this is trivially simple in Ruby even using classes. Is there some other benefit?
In that case, you just need an immutable data-structure and some metadata. No need to mess around with opaque, mutable objects.