Class | Dissident::Cache |
In: |
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 dissident.rb, line 232 232: def fetch(name, *args) 233: @values.fetch(name) { 234: @values[name] = {} 235: }.fetch(args) { 236: unless @container.respond_to? name 237: raise MissingServiceError, 238: "no service `#{name}' defined in #@container" 239: end 240: 241: service = @container.__send__(name, *args) 242: unless service.kind_of? Prototype 243: @values[name][args] = service 244: else 245: service.call # Evaluate the prototype, don't cache. 246: end 247: } 248: end