Class: IdentityCache::CacheFetcher::FillLock

Inherits:
Object
  • Object
show all
Defined in:
lib/identity_cache/cache_fetcher.rb

Constant Summary collapse

FILL_LOCKED =
:fill_locked
FAILED_CLIENT_ID =
"fill_failed"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id:, data_version:) ⇒ FillLock

Returns a new instance of FillLock.



29
30
31
32
# File 'lib/identity_cache/cache_fetcher.rb', line 29

def initialize(client_id:, data_version:)
  @client_id = client_id
  @data_version = data_version
end

Instance Attribute Details

#client_idObject (readonly)

Returns the value of attribute client_id.



27
28
29
# File 'lib/identity_cache/cache_fetcher.rb', line 27

def client_id
  @client_id
end

#data_versionObject (readonly)

Returns the value of attribute data_version.



27
28
29
# File 'lib/identity_cache/cache_fetcher.rb', line 27

def data_version
  @data_version
end

Class Method Details

.cache_value?(cache_value) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/identity_cache/cache_fetcher.rb', line 22

def cache_value?(cache_value)
  cache_value.is_a?(Array) && cache_value.length == 3 && cache_value.first == FILL_LOCKED
end

.from_cache(marker, client_id, data_version) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
# File 'lib/identity_cache/cache_fetcher.rb', line 16

def from_cache(marker, client_id, data_version)
  raise ArgumentError unless marker == FILL_LOCKED

  new(client_id: client_id, data_version: data_version)
end

Instance Method Details

#==(other) ⇒ Object



46
47
48
# File 'lib/identity_cache/cache_fetcher.rb', line 46

def ==(other)
  self.class == other.class && client_id == other.client_id && data_version == other.data_version
end

#cache_valueObject



34
35
36
# File 'lib/identity_cache/cache_fetcher.rb', line 34

def cache_value
  [FILL_LOCKED, client_id, data_version]
end

#fill_failed?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/identity_cache/cache_fetcher.rb', line 42

def fill_failed?
  @client_id == FAILED_CLIENT_ID
end

#mark_failedObject



38
39
40
# File 'lib/identity_cache/cache_fetcher.rb', line 38

def mark_failed
  @client_id = FAILED_CLIENT_ID
end