Class: DataPipe2::Jobs

Inherits:
Object
  • Object
show all
Defined in:
lib/jobs.rb

Overview

Hold all jobs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeJobs

Returns a new instance of Jobs.



67
68
69
70
# File 'lib/jobs.rb', line 67

def initialize
  @hash = {}
  @by_name = {}
end

Instance Attribute Details

#byNameObject (readonly)

Returns the value of attribute byName.



65
66
67
# File 'lib/jobs.rb', line 65

def byName
  @byName
end

#hashObject (readonly)

Returns the value of attribute hash.



65
66
67
# File 'lib/jobs.rb', line 65

def hash
  @hash
end

Instance Method Details

#call(path) ⇒ Object



72
73
74
75
76
77
78
79
80
81
# File 'lib/jobs.rb', line 72

def call(path)
  if @hash[path].nil?
    j = Job.new(path)
    @hash[path] = j
    @by_name[j.name.downcase] = j
    j.run
  else
    @hash[path].call
  end
end