Class: Travis::Lock::Postgresql

Inherits:
Struct
  • Object
show all
Defined in:
lib/travis/lock/postgresql.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePostgresql

Returns a new instance of Postgresql.



17
18
19
20
# File 'lib/travis/lock/postgresql.rb', line 17

def initialize(*)
  super
  fail 'lock name cannot be blank' if name.nil? || name.empty?
end

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



16
17
18
# File 'lib/travis/lock/postgresql.rb', line 16

def name
  @name
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



16
17
18
# File 'lib/travis/lock/postgresql.rb', line 16

def options
  @options
end

Instance Method Details

#exclusive(&block) ⇒ Object



22
23
24
25
# File 'lib/travis/lock/postgresql.rb', line 22

def exclusive(&block)
  with_timeout { obtain_lock }
  transactional? ? connection.transaction(&block) : with_release(&block)
end