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

Attribute setter return value.

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 4.0.0 final
    • Component/s: None
    • Labels:

      Description

      I would say, that this is not a bug, but quite an unobvious behaviour:

      >> City.new.country_id = Country.new.id
      "50bcc9c75b9e058d6a000004"
      >> City.new.send(:country_id=, Country.new.id)
      false
      >> City.new.send(:population=, 5)
      nil
      >> City.new.population = 5
      5

      And there is the same problem with calling super inside a redefinition of an attribute setter field.
      There was not such a problem with Mongoid 2.
      I think that the most obvious behaviour for a method with = is to have the parameter as the return value, so that it works the same independently of the way it was called.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: