Skip to content

Commit

Permalink
feat: delegate Esse.cluster to Esse.config.cluster to simplify search…
Browse files Browse the repository at this point in the history
… calls
  • Loading branch information
marcosgz committed Nov 14, 2023
1 parent 3e63564 commit ceea2db
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/esse/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
require_relative 'transport'

module Esse
class << self
extend Forwardable

def_delegators :config, :cluster
end

class Cluster
ATTRIBUTES = %i[index_prefix settings mappings client wait_for_status readonly].freeze
WAIT_FOR_STATUSES = %w[green yellow red].freeze
Expand Down Expand Up @@ -133,7 +139,7 @@ def info
end

def engine
@engine ||=ClusterEngine.new(**info)
@engine ||= ClusterEngine.new(**info)
end
alias_method :warm_up!, :engine

Expand Down
9 changes: 9 additions & 0 deletions spec/esse_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
it { expect { described_class.config(&:to_s) }.not_to raise_error }
end

describe '.cluster' do
it { expect(described_class).to respond_to(:cluster) }

it 'delegates to Esse::Config#cluster' do
expect(described_class.config).to receive(:cluster).and_call_original
described_class.cluster
end
end

describe '.timestamp' do
it { expect(Esse.timestamp).to be_kind_of(String) }
end
Expand Down

0 comments on commit ceea2db

Please sign in to comment.