Skip to content

Commit 29ca681

Browse files
committed
[MODEL] Improved including importing modules into the proxy
`class_eval` is less magical then meta-class, though meta-class is the _why way and so it's kept in the project history.
1 parent 28e3124 commit 29ca681

File tree

1 file changed

+5
-5
lines changed
  • elasticsearch-model/lib/elasticsearch

1 file changed

+5
-5
lines changed

elasticsearch-model/lib/elasticsearch/model.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ def as_indexed_json(options={})
105105
forward :'self.__elasticsearch__', :settings unless respond_to?(:settings)
106106
forward :'self.__elasticsearch__', :index_name unless respond_to?(:index_name)
107107
forward :'self.__elasticsearch__', :document_type unless respond_to?(:document_type)
108+
forward :'self.__elasticsearch__', :import unless respond_to?(:import)
108109

109110
# Mix the importing module into the proxy
110111
#
111-
proxy_class = class << self.__elasticsearch__; self; end
112-
proxy_class.__send__ :include, Elasticsearch::Model::Importing::ClassMethods
113-
proxy_class.__send__ :include, Adapter.from_class(base).importing_mixin
114-
115-
forward :'self.__elasticsearch__', :import unless respond_to?(:import)
112+
self.__elasticsearch__.class_eval do
113+
include Elasticsearch::Model::Importing::ClassMethods
114+
include Adapter.from_class(base).importing_mixin
115+
end
116116
end
117117
end
118118

0 commit comments

Comments
 (0)