Skip to content

Commit 26563ee

Browse files
tpitaletylerjl
authored andcommitted
[MODEL] Add Callbacks to the example datamapper adapter
I added these callbacks in my code, and thought it might be useful for other people. Closes elastic#220
1 parent 71b4ed9 commit 26563ee

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

elasticsearch-model/examples/datamapper_article.rb

+10
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ def records
5555

5656
# ...
5757
end
58+
59+
module Callbacks
60+
def self.included(model)
61+
model.class_eval do
62+
after(:create) { __elasticsearch__.index_document }
63+
after(:save) { __elasticsearch__.update_document }
64+
after(:destroy) { __elasticsearch__.delete_document }
65+
end
66+
end
67+
end
5868
end
5969

6070
# Register the adapter

0 commit comments

Comments
 (0)