Class: MatViews::Services::CheckMatviewExists

Inherits:
BaseService
  • Object
show all
Defined in:
lib/mat_views/services/check_matview_exists.rb

Overview

MatViews::Services::CheckMatviewExists


Service object that checks whether the underlying PostgreSQL **materialised view** for a given MatViewDefinition currently exists.

### Contract

  • Inherits from BaseService.

  • Uses BaseService helpers such as ‘definition`, `view_exists?`, `ok`, `raise_err`, and the `request`/`response` accessors.

  • The public entrypoint is ‘#call` (defined in BaseService), which will call the private lifecycle hooks here: #prepare, #assign_request, and #_run.

### Result

  • On success: status ‘:ok`, with `response: { exists: true|false }`.

  • On validation failure (bad view name): raises via BaseService#raise_err.

Examples:

Check if a materialised view exists

defn = MatViews::MatViewDefinition.find(1)
res  = MatViews::Services::CheckMatviewExists.new(defn).call
if res.success?
  puts res.response[:exists] ? "Exists" : "Missing"
else
  warn res.error
end

See Also:

Constant Summary

Constants inherited from BaseService

BaseService::ALLOWED_ROW_STRATEGIES, BaseService::DEFAULT_NIL_STRATEGY, BaseService::DEFAULT_ROW_STRATEGY, BaseService::UNKNOWN_ROW_COUNT

Instance Attribute Summary

Attributes inherited from BaseService

#definition, #request, #response, #row_count_strategy, #use_transaction

Method Summary

Methods inherited from BaseService

#call, #initialize

Constructor Details

This class inherits a constructor from MatViews::Services::BaseService