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

Attribute setter return value.

    • Type: Icon: Task Task
    • Resolution: Done
    • 4.0.0 final
    • Affects Version/s: None
    • Component/s: None

      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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            exoth Yuriy Trofimenko
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: