Class: Agent::Lock::CLI::Commands::Release

Inherits:
TreeCommand
  • Object
show all
Defined in:
lib/agent/lock/cli/commands/release.rb

Overview

Give a scope back.

Instance Attribute Summary

Attributes inherited from Base

#launcher

Instance Method Summary collapse

Methods inherited from TreeCommand

inherited

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Agent::Lock::CLI::Commands::Base

Instance Method Details

#call(scope:, **options) ⇒ Manager::Result

Returns :released, :not_found or :refused.

Parameters:

  • scope (String) —

    the scope exactly as it was claimed

  • options (Hash) —

    :dir, :locking_strategy, :redis_url

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/agent/lock/cli/commands/release.rb', line 20

def call(scope:, **options)
  result = manager(options).release(scope)

  case result.status
  when :released then say("RELEASED #{scope_of(result.record)}")
  when :not_found then say("NOT LOCKED #{scope}")
  when :refused
    warn_("REFUSED: #{scope_of(result.record)} is held by #{holder_of(result.record)}, not you")
  end

  finish(result)
end