Skip to content

Commit 4bacc71

Browse files
committed
[GEM] Refactors Gem and Transport relationship
Initial commit on extracting Elasticsearch specific code from elasticsearch-transport and into the elasticsearch gem. We're now using transport for elastic-enterprise-search too.
1 parent 8245b46 commit 4bacc71

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

elasticsearch-transport/lib/elasticsearch/transport.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,3 @@
3535
require "elasticsearch/transport/redacted"
3636

3737
require "elasticsearch/transport/version"
38-
39-
module Elasticsearch
40-
module Client
41-
42-
# A convenience wrapper for {::Elasticsearch::Transport::Client#initialize}.
43-
#
44-
def new(arguments={}, &block)
45-
Elasticsearch::Transport::Client.new(arguments, &block)
46-
end
47-
extend self
48-
end
49-
end

elasticsearch-transport/lib/elasticsearch/transport/client.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ def initialize(arguments = {}, &block)
176176
end
177177
end
178178
end
179-
180179
# Performs a request through delegation to {#transport}.
181180
#
182181
def perform_request(method, path, params = {}, body = nil, headers = nil)

elasticsearch/lib/elasticsearch.rb

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,27 @@
2020
require 'elasticsearch/api'
2121

2222
module Elasticsearch
23-
module Transport
24-
class Client
25-
include Elasticsearch::API
23+
class Client
24+
include Elasticsearch::API
25+
26+
def initialize(arguments = {}, &block)
27+
@transport = Elasticsearch::Transport::Client.new(arguments, &block)
28+
end
29+
30+
def method_missing(name, *args, &block)
31+
if methods.include?(name)
32+
super
33+
else
34+
@transport.send(name, *args, &block)
35+
end
36+
end
37+
38+
def respond_to_missing?(method_name, *args)
39+
@transport.respond_to?(method_name) || super
2640
end
2741
end
2842
end
43+
2944
module Elastic
3045
# If the version is X.X.X.pre/alpha/beta, use X.X.Xp for the meta-header:
3146
def self.client_meta_version

0 commit comments

Comments
 (0)