Class: Jets::CLI::Maintenance::Web

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/cli/maintenance/web.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#paginate, #paging_params, rescue_api_error

Methods included from Util::Logging

#log

Methods included from AwsServices

#apigateway, #aws_options, #cfn, #codebuild, #dynamodb, #lambda_client, #logs, #s3, #s3_resource, #sns, #sqs, #ssm, #sts, #wafv2

Methods included from AwsServices::StackStatus

#output_value, #stack_exists?

Methods included from AwsServices::GlobalMemoist

included, #reset_cache!

Methods included from Api

#api, #api_key

Constructor Details

#initialize(options = {}) ⇒ Web

Returns a new instance of Web.



3
4
5
6
7
# File 'lib/jets/cli/maintenance/web.rb', line 3

def initialize(options = {})
  super
  function_name = Jets::CLI::Lambda::Lookup.function("controller")
  @lambda_function = Jets::CLI::Lambda::Function.new(function_name)
end

Instance Method Details

#offObject



18
19
20
21
22
23
24
25
# File 'lib/jets/cli/maintenance/web.rb', line 18

def off
  if on?
    @lambda_function.environment_variables = {JETS_MAINTENANCE: nil}
    warn "Web maintenance has been turned off"
  else
    warn "Web maintenance is already off"
  end
end

#onObject



9
10
11
12
13
14
15
16
# File 'lib/jets/cli/maintenance/web.rb', line 9

def on
  if on?
    warn "Web maintenance is already on"
  else
    @lambda_function.environment_variables = {JETS_MAINTENANCE: "on"}
    warn "Web maintenance has been turned on"
  end
end

#on?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/jets/cli/maintenance/web.rb', line 27

def on?
  truthy?(@lambda_function.environment_variables["JETS_MAINTENANCE"])
end