Class: DiscoveryV1::Validation::LoadSchemas Private
- Inherits:
-
Object
- Object
- DiscoveryV1::Validation::LoadSchemas
- Defined in:
- lib/discovery_v1/validation/load_schemas.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Load the Google Discovery V1 API description for the Discovery V1 API
Class Attribute Summary collapse
-
.load_schemas_mutex ⇒ Thread::Mutex
readonly
private
A mutex used to synchronize access to the schemas so they are only loaded once.
Instance Attribute Summary collapse
-
#logger ⇒ Logger
readonly
private
The logger to use internally for logging errors.
-
#rest_description ⇒ Google::Apis::DiscoveryV1::RestDescription
readonly
private
The Google Discovery V1 API description to load schemas from.
Class Method Summary collapse
-
.clear_schemas_cache
private
Clear the memoization cache (intended for testing).
-
.memoize_schemas(rest_description:, schemas:) ⇒ Hash<String, Object>
private
Memoize the schemas for the given rest_description returning the given schemas.
-
.schemas(rest_description:) ⇒ Hash<String, Object>?
private
The memoized schemas for the given rest_description or nil.
Instance Method Summary collapse
-
#call ⇒ Hash<String, Object>
private
A hash of schemas keyed by schema name loaded from the Google Discovery V1 API.
-
#initialize(rest_description:, logger: Logger.new(nil)) ⇒ LoadSchemas
constructor
private
Loads schemas for the Discovery V1 API object from the Google Discovery V1 API.
Constructor Details
#initialize(rest_description:, logger: Logger.new(nil)) ⇒ LoadSchemas
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Loads schemas for the Discovery V1 API object from the Google Discovery V1 API
By default, a nil logger is used. This means that nothing is logged.
The schemas are only loaded once and cached.
30 31 32 33 |
# File 'lib/discovery_v1/validation/load_schemas.rb', line 30 def initialize(rest_description:, logger: Logger.new(nil)) @rest_description = rest_description @logger = logger end |
Class Attribute Details
.load_schemas_mutex ⇒ Thread::Mutex (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
A mutex used to synchronize access to the schemas so they are only loaded once
99 100 101 |
# File 'lib/discovery_v1/validation/load_schemas.rb', line 99 def load_schemas_mutex @load_schemas_mutex end |
Instance Attribute Details
#logger ⇒ Logger (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The logger to use internally for logging errors
55 56 57 |
# File 'lib/discovery_v1/validation/load_schemas.rb', line 55 def logger @logger end |
#rest_description ⇒ Google::Apis::DiscoveryV1::RestDescription (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The Google Discovery V1 API description to load schemas from
44 45 46 |
# File 'lib/discovery_v1/validation/load_schemas.rb', line 44 def rest_description @rest_description end |
Class Method Details
.clear_schemas_cache
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Clear the memoization cache (intended for testing)
134 135 136 |
# File 'lib/discovery_v1/validation/load_schemas.rb', line 134 def clear_schemas_cache @schemas_cache = {} end |
.memoize_schemas(rest_description:, schemas:) ⇒ Hash<String, Object>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Memoize the schemas for the given rest_description returning the given schemas
124 125 126 |
# File 'lib/discovery_v1/validation/load_schemas.rb', line 124 def memoize_schemas(rest_description:, schemas:) @schemas_cache[rest_description.canonical_name] = schemas end |
.schemas(rest_description:) ⇒ Hash<String, Object>?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The memoized schemas for the given rest_description or nil
110 111 112 |
# File 'lib/discovery_v1/validation/load_schemas.rb', line 110 def schemas(rest_description:) @schemas_cache[rest_description.canonical_name] end |
Instance Method Details
#call ⇒ Hash<String, Object>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
A hash of schemas keyed by schema name loaded from the Google Discovery V1 API
64 65 66 67 68 69 |
# File 'lib/discovery_v1/validation/load_schemas.rb', line 64 def call self.class.load_schemas_mutex.synchronize do self.class.schemas(rest_description:) || self.class.memoize_schemas(rest_description:, schemas: load_api_schemas) end end |