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?
Not monkey-patching the class, rather extending actual object instances by dynamically mixing in modules. The two are very different ;-)
I did not know about clojure :pre and :post. Certainly very powerful feature baked into the language.
Now what else is it that I don't know.
Guess it's time to get Joy of Clojure!