Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5638

Document idempotence of #mongoize for custom types

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Trivial - P5 Trivial - P5
    • None
    • Affects Version/s: None
    • Component/s: Docs
    • None

      MONGOID-5633 revealed a lack in our documentation: if someone wants to develop a custom type for a field, they need to make sure the type's #mongoize method is idempotent.

      This is because #mongoize may be called on a value that has already been #mongoize'd, such as when creating a record via #first_or_create. In this case, any prior selector (which will have been mongoize'd as it was constructed) will be passed verbatim as attributes to the new document, and then the process of initializing the new document will call #mongoize again on those fields.

      So, we need to make sure the documentation mentions that #mongoize needs to be able to accept a value that has already been #mongoize'd.

            Assignee:
            Unassigned Unassigned
            Reporter:
            jamis.buck@mongodb.com Jamis Buck
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: