Class: Postjob::Host

Inherits:
Record
  • Object
show all
Defined in:
lib/postjob/host.rb

Constant Summary collapse

UUID_REGEXP =
/\A[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\z/i

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Record

#initialize

Constructor Details

This class inherits a constructor from Postjob::Record

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/postjob/host.rb', line 6

def attributes
  @attributes
end

#created_atObject (readonly)

Returns the value of attribute created_at.



8
9
10
# File 'lib/postjob/host.rb', line 8

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/postjob/host.rb', line 5

def id
  @id
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/postjob/host.rb', line 7

def status
  @status
end

Class Method Details

.clear_storageObject



11
12
13
14
15
# File 'lib/postjob/host.rb', line 11

def clear_storage
  @host_id = nil

  File.unlink(storage_path) if File.exist?(storage_path)
end

.host_idObject



28
29
30
# File 'lib/postjob/host.rb', line 28

def host_id
  @host_id ||= atomic_set_and_get(storage_path) { register_host(host_id: nil) }
end

.host_id=(host_id) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/postjob/host.rb', line 19

def host_id=(host_id)
  expect! host_id => UUID_REGEXP

  return if @host_id == host_id

  register_host(host_id: host_id)
  @host_id = host_id
end