Class: PagerDuty::ChefServer::SyncLock
- Inherits:
-
Object
- Object
- PagerDuty::ChefServer::SyncLock
- Defined in:
- lib/pagerduty/chef_server/synclock.rb
Instance Method Summary collapse
-
#initialize(lockfile, server_hostname, local_hostname, user, branch, force_lock = false) ⇒ SyncLock
constructor
A new instance of SyncLock.
-
#lock(time = Time.now) ⇒ Object
get lock.
-
#unlock ⇒ Object
remove lock.
Constructor Details
#initialize(lockfile, server_hostname, local_hostname, user, branch, force_lock = false) ⇒ SyncLock
Returns a new instance of SyncLock.
27 28 29 30 31 32 33 34 |
# File 'lib/pagerduty/chef_server/synclock.rb', line 27 def initialize(lockfile, server_hostname, local_hostname, user, branch, force_lock = false) @lockfile = lockfile @server_hostname = server_hostname.include?('.') ? server_hostname.split('.')[0] : server_hostname @local_hostname = local_hostname @user = user @branch = branch @opts = parse_opts({ announce: true, lock: true, force: force_lock }) end |
Instance Method Details
#lock(time = Time.now) ⇒ Object
get lock
37 38 39 40 41 |
# File 'lib/pagerduty/chef_server/synclock.rb', line 37 def lock(time = Time.now) verify_lockable @f_lock = procure_lock if @opts[:lock] || @opts[:force] end |