class EntityCache::Store::Internal
Attributes
subject[RW]
Public Class Methods
build(subject)
click to toggle source
# File lib/entity_cache/store/internal.rb, line 9 def self.build(subject) instance = new instance.subject = subject instance end
configure(receiver, subject, scope: nil, attr_name: nil)
click to toggle source
# File lib/entity_cache/store/internal.rb, line 15 def self.configure(receiver, subject, scope: nil, attr_name: nil) attr_name ||= :internal_store instance = Build.(subject, scope: scope) receiver.public_send("#{attr_name}=", instance) instance end
Public Instance Methods
count()
click to toggle source
# File lib/entity_cache/store/internal.rb, line 51 def count records.count end
Also aliased as: length
delete(id)
click to toggle source
# File lib/entity_cache/store/internal.rb, line 47 def delete(id) records.delete(id) end
empty?()
click to toggle source
# File lib/entity_cache/store/internal.rb, line 56 def empty? records.empty? end
get(id)
click to toggle source
# File lib/entity_cache/store/internal.rb, line 25 def get(id) logger.trace { "Getting Entity (ID: #{id.inspect})" } record = records[id] logger.debug { "Get entity done (ID: #{id.inspect}, #{Record::LogText.get(record)})" } record end
put(record)
click to toggle source
# File lib/entity_cache/store/internal.rb, line 35 def put(record) id = record.id logger.trace { "Putting entity (ID: #{id.inspect}, #{Record::LogText.get(record)})" } records[id] = record logger.trace { "Put entity done (ID: #{id.inspect}, #{Record::LogText.get(record)})" } record end