Module: ElastomerClient::Client::RestApiSpec
- Defined in:
- lib/elastomer_client/client/rest_api_spec.rb,
lib/elastomer_client/client/rest_api_spec/api_spec.rb,
lib/elastomer_client/client/rest_api_spec/rest_api.rb,
lib/elastomer_client/client/rest_api_spec/api_spec_v5_6.rb,
lib/elastomer_client/client/rest_api_spec/api_spec_v8_7.rb,
lib/elastomer_client/client/rest_api_spec/api_spec_v8_13.rb
Overview
Generated REST API spec file - DO NOT EDIT! Date: 2024-04-05 ES version: 8.13
Defined Under Namespace
Classes: ApiSpec, ApiSpecV5_6, ApiSpecV8_13, ApiSpecV8_7, RestApi
Class Method Summary collapse
-
.api_spec(version) ⇒ Object
Returns an ApiSpec instance for the given Elasticsearcion version.
-
.load_api_spec(version) ⇒ Object
Internal: Load the specific ApiSpec version class for the given version.
-
.to_class_version(version) ⇒ Object
Internal: Convert a dotted version String into an underscore format suitable for use in Ruby class names.
Class Method Details
.api_spec(version) ⇒ Object
Returns an ApiSpec instance for the given Elasticsearcion version. This method will load the ApiSpec version class if it has not already been defined. This prevents bloat by only loading the version specs that are needed.
Because of this lazy loading, this method is not thread safe.
version - the Elasticsearch version String
Returns the requested ApiSpec version if available
19 20 21 22 23 |
# File 'lib/elastomer_client/client/rest_api_spec.rb', line 19 def self.api_spec(version) classname = "ApiSpecV#{to_class_version(version)}" load_api_spec(version) if !self.const_defined? classname self.const_get(classname).new end |
.load_api_spec(version) ⇒ Object
Internal: Load the specific ApiSpec version class for the given version.
26 27 28 29 30 31 32 33 |
# File 'lib/elastomer_client/client/rest_api_spec.rb', line 26 def self.load_api_spec(version) path = File.("../rest_api_spec/api_spec_v#{to_class_version(version)}.rb", __FILE__) if File.exist? path load path else raise RuntimeError, "Unsupported REST API spec version: #{version}" end end |
.to_class_version(version) ⇒ Object
Internal: Convert a dotted version String into an underscore format suitable for use in Ruby class names.
37 38 39 |
# File 'lib/elastomer_client/client/rest_api_spec.rb', line 37 def self.to_class_version(version) version.to_s.split(".").slice(0, 2).join("_") end |