Class: EntityCache::Store::Internal::Substitute::Internal

Inherits:
EntityCache::Store::Internal::Scope::Exclusive show all
Defined in:
lib/entity_cache/store/internal/substitute.rb

Instance Attribute Summary

Attributes inherited from EntityCache::Store::Internal

#subject

Instance Method Summary collapse

Methods inherited from EntityCache::Store::Internal::Scope::Exclusive

#records

Methods inherited from EntityCache::Store::Internal

build, configure, #count, #delete, #empty?, #get, #put

Instance Method Details

#add(id, entity, version, time, persisted_version: nil, persisted_time: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/entity_cache/store/internal/substitute.rb', line 10

def add(id, entity, version, time, persisted_version: nil, persisted_time: nil)
  record = Record.build(
    id,
    entity,
    version,
    time,
    persisted_version: persisted_version,
    persisted_time: persisted_time
  )

  put(record)
end

#put?(record = nil) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
# File 'lib/entity_cache/store/internal/substitute.rb', line 23

def put?(record=nil)
  if record.nil?
    records.any?
  else
    records.any? do |_, r|
      r == record
    end
  end
end