-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
Not sure if this is a bug or feature, but attributes marked as read-only can still be modified using #inc (and presumably other) atomic operations:
Against master (@ 030442e):
require "bundler/setup" require "mongoid" Mongoid::Config.connect_to("mongoid_test") class Foo include Mongoid::Document field :bar, type: Integer attr_readonly :bar end foo = Foo.create(bar: 5) foo.reload.bar # => 5 (as expected) foo.update_attributes(bar: 6) foo.reload.bar # => 5 (as expected) foo.set(bar: 6) foo.reload.bar # => 5 (as expected) foo.inc(bar: 1) foo.reload.bar # => 6 (shouldn't happen!)
If that's by design, it should probably be documented.