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

Add an example overriding field accessors with read/write_attribute

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Docs
    • None

      Add an example (and a test if we don't have one) that transforms values using write_attribute and read_attribute, taking effect before serialization and after deserialization respectively. E.g. to retrieve field values in upper case:

      class Band
        def foo
          read_attribute(:foo).upcase
        end
      end
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: