We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
@mymodel.id=
1 parent fc55ab3 commit fad8b50Copy full SHA for fad8b50
elasticsearch-persistence/lib/elasticsearch/persistence/model/base.rb
@@ -25,6 +25,12 @@ def id
25
@_id
26
end; alias :_id :id
27
28
+ # Set the document `_id`
29
+ #
30
+ def id=(value)
31
+ @_id = value
32
+ end; alias :_id= :id=
33
+
34
# Return the document `_index`
35
#
36
def _index
elasticsearch-persistence/test/unit/model_base_test.rb
@@ -27,6 +27,14 @@ class DummyBaseModel
assert_equal 2, m.id
end
+ should "set the ID using setter method" do
+ m = DummyBaseModel.new id: 1
+ assert_equal 1, m.id
+ m.id = 2
+ assert_equal 2, m.id
+ end
37
38
should "have ID in attributes" do
39
m = DummyBaseModel.new id: 1, name: 'Test'
40
assert_equal 1, m.attributes[:id]
0 commit comments