Class | Dissident::Cache |
In: |
lib/nukumi2/vendor/dissident.rb
|
Parent: | Object |
Dissident::Cache keeps track of instantiated services by implementing a multiton instantiation scheme.
to_s | -> | inspect |
Don‘t clutter up inspects. |
Instantiate the service name with the optional arguments args. Services that are of class Prototype will be evaluated on each request.
# File lib/nukumi2/vendor/dissident.rb, line 241 241: def fetch(name, *args) 242: @values.fetch(name) { 243: @values[name] = {} 244: }.fetch(args) { 245: unless @container.respond_to? name 246: raise MissingServiceError, 247: "no service `#{name}' defined in #@container" 248: end 249: 250: service = @container.__send__(name, *args) 251: unless service.kind_of? Prototype 252: @values[name][args] = service 253: else 254: service.call # Evaluate the prototype, don't cache. 255: end 256: } 257: end