Class: Dragonfly::JobDefinitions

Inherits:
Module
  • Object
show all
Defined in:
lib/dragonfly/job_definitions.rb

Instance Method Summary (collapse)

Constructor Details

- (JobDefinitions) initialize

Returns a new instance of JobDefinitions



4
5
6
# File 'lib/dragonfly/job_definitions.rb', line 4

def initialize
  @job_definitions = {}
end

Instance Method Details

- (Object) add(name, &definition_proc)



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dragonfly/job_definitions.rb', line 8

def add(name, &definition_proc)
  job_definitions[name] = JobBuilder.new(&definition_proc)
  jd = job_definitions # Needed because we're about to change 'self'
  
  define_method name do |*args|
    jd[name].build(self, *args)
  end
  
  define_method "#{name}!" do |*args|
    jd[name].build!(self, *args)
  end
end

- (Object) definition_names



21
22
23
# File 'lib/dragonfly/job_definitions.rb', line 21

def definition_names
  job_definitions.keys
end