Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
entity_cache / lib / entity_cache / storage / temporary.rb
Size: Mime:
class EntityCache
  module Storage
    class Temporary
      attr_reader :subject

      dependency :logger, Telemetry::Logger

      def initialize(subject)
        @subject = subject
      end

      def self.build(subject)
        instance = new subject
        Telemetry::Logger.configure instance
        instance
      end

      def self.configure(receiver, subject, scope: nil, attr_name: nil)
        attr_name ||= :temporary_store

        instance = Factory.(subject, scope: scope)
        receiver.public_send "#{attr_name}=", instance
        instance
      end

      def get(id)
        records[id]
      end

      def put(record)
        records[record.id] = record
      end

      abstract :records

      module Assertions
        def empty?
          records.empty?
        end

        def put?(record)
          records[record.id] == record
        end
      end

      module Substitute
        def self.build
          Scope::Exclusive.build :substitute
        end
      end
    end
  end
end