Method: WebappWorker::Job#initialize

Defined in:
lib/webapp_worker/job.rb

#initialize(user_supplied_hash = {}) ⇒ Job

Returns a new instance of Job.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/webapp_worker/job.rb', line 11

def initialize(user_supplied_hash={})
  standard_hash = { command:"", minute:"*", hour:"*", day:"*", month:"*", weekday:"*" }

  user_supplied_hash = {} unless user_supplied_hash
  user_supplied_hash = standard_hash.merge(user_supplied_hash)

  user_supplied_hash.each do |key,value|
    self.instance_variable_set("@#{key}", value)
    self.class.send(:define_method, key, proc{self.instance_variable_get("@#{key}")})
    self.class.send(:define_method, "#{key}=", proc{|x| self.instance_variable_set("@#{key}", x)})
  end

  self.parse_datetime
end