Class Tap::Tasks::Singleton
In: lib/tap/tasks/singleton.rb
Parent: Tap::Task

Methods

cache   call   new   new   reset  

Attributes

cache  [R] 
signature  [R] 

Public Class methods

[Source]

   # File lib/tap/tasks/singleton.rb, line 7
7:         def cache
8:           @cache ||= {}
9:         end

[Source]

    # File lib/tap/tasks/singleton.rb, line 11
11:         def new(*args)
12:           obj = super
13:           cache[obj.signature] ||= obj
14:         end

[Source]

    # File lib/tap/tasks/singleton.rb, line 20
20:       def initialize(config={}, app=Tap::App.current)
21:         @signature = [config.dup, app].freeze
22:         super(config, app)
23:         reset
24:       end

Public Instance methods

[Source]

    # File lib/tap/tasks/singleton.rb, line 26
26:       def call(input)
27:         cache.has_key?(input) ? cache[input] : cache[input] = super
28:       end

[Source]

    # File lib/tap/tasks/singleton.rb, line 30
30:       def reset
31:         @cache = {}
32:       end

[Validate]