lib/momento/create_cache_response.rb in momento-0.1.0 vs lib/momento/create_cache_response.rb in momento-0.2.0
- old
+ new
@@ -1,51 +1,36 @@
-require 'grpc'
-require 'momento/controlclient_pb'
+require_relative 'response/error'
module Momento
- # Responses specific to create_cache.
+ # A response from creating a cache.
class CreateCacheResponse < Response
- # Build a Momento::CreateCacheResponse from a block of code
- # which returns a Momento::ControlClient::CreateCacheResponse.
- #
- # @return [Momento::CreateCacheResponse]
- # @raise [StandardError] when the exception is not recognized.
- # @raise [TypeError] when the response is not recognized.
- def self.from_block
- response = yield
- rescue GRPC::AlreadyExists
- return AlreadyExists.new
- rescue GRPC::BadStatus => e
- Error.new(grpc_exception: e)
- else
- raise TypeError unless response.is_a?(Momento::ControlClient::CreateCacheResponse)
-
- return Success.new
- end
-
+ # Does the cache already exist?
+ # @return [Boolean]
def already_exists?
false
end
+ # Was the cache created?
+ # @return [Boolean]
def success?
false
end
- # A cache with that name already exists.
+ # @private
class AlreadyExists < CreateCacheResponse
def already_exists?
true
end
end
- # The cache was created.
+ # @private
class Success < CreateCacheResponse
def success?
true
end
end
- # There was an error creating the cache.
+ # @private
class Error < CreateCacheResponse
include ::Momento::Response::Error
end
end
end