Class: Smriti::Services::CheckMatviewExists

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

Overview

Smriti::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 = Smriti::MatViewDefinition.find(1)
res  = Smriti::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 Smriti::Services::BaseService