Module | Ohm::Utils |
In: |
lib/ohm.rb
|
Instead of monkey patching Kernel or trying to be clever, it‘s best to confine all the helper methods in a Utils module.
Used by: `attribute`, `counter`, `set`, `reference`, `collection`.
Employed as a solution to avoid `NameError` problems when trying to load models referring to other models not yet loaded.
Example:
class Comment < Ohm::Model reference :user, User # NameError undefined constant User. end # Instead of relying on some clever `const_missing` hack, we can # simply use a symbol or a string. class Comment < Ohm::Model reference :user, :User reference :post, "Post" end