Mostly in rails if you write my_obj.attr
it looks up attr
in the database and reports it back. How do you create a custom def attr
method that internally queries the database for attr
, modifies it and returns? In other words, what's the missing piece here:
# Within a model. Basic attr_reader method, will later modify the body.
def attr
get_from_database :attr # <-- how do I get the value of attr from the db?
end