Class: Mule::Configurator

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path) ⇒ Configurator

Returns a new instance of Configurator.



6
7
8
9
10
11
12
13
# File 'lib/mule/configurator.rb', line 6

def initialize(config_path)
  @config        = config_path
  @jobs          = []
  @events        = {
    :before_fork => Proc.new {},
    :after_fork  => Proc.new {}
  }
end

Instance Attribute Details

#eventsObject (readonly)

Returns the value of attribute events.



4
5
6
# File 'lib/mule/configurator.rb', line 4

def events
  @events
end

#jobsObject (readonly)

Returns the value of attribute jobs.



4
5
6
# File 'lib/mule/configurator.rb', line 4

def jobs
  @jobs
end

Instance Method Details

#add_job(&block) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/mule/configurator.rb', line 25

def add_job(&block)
  if block_given?
    job = Job.new
    yield job
    @jobs << job
  end
end

#after_fork(&block) ⇒ Object



37
38
39
# File 'lib/mule/configurator.rb', line 37

def after_fork(&block)
  @events[:after_fork] = block if block_given?
end

#before_fork(&block) ⇒ Object



33
34
35
# File 'lib/mule/configurator.rb', line 33

def before_fork(&block)
  @events[:before_fork] = block if block_given?
end

#config_contentObject



20
21
22
23
# File 'lib/mule/configurator.rb', line 20

def config_content
  raise Mule::Error::MissingConfig unless File.exists?(@config)
  File.read(@config)
end

#parse!Object



15
16
17
18
# File 'lib/mule/configurator.rb', line 15

def parse!
  instance_eval(config_content, @config)
  self
end