Module: Djinn::Base::Dsl

Defined in:
lib/djinn/base/dsl.rb

Overview

Defines the awesomesauce DSL defining your Djinn

Defined Under Namespace

Classes: ConfigHelper, ConfigItem, DjinnActionError, DslDefinitionHelper

Instance Method Summary collapse

Instance Method Details

#djinn(&block) ⇒ Object

Start your Djinn definition



9
10
11
12
13
14
15
16
17
18
# File 'lib/djinn/base/dsl.rb', line 9

def djinn &block
  @definition = DslDefinitionHelper.new(&block)
  @definition.actions.each do |action, proc|
    module_eval do
      define_method "__#{action}!".intern do |*args|
        instance_exec(&proc)
      end
    end
  end
end

#djinnify(config = {}) ⇒ Object

Create an instance of your Djinn, interpret any command line switches defined in your configuration block, and starts the Djinn in the background



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/djinn/base/dsl.rb', line 23

def djinnify config={}
  djinn = new
  @definition.prepare(djinn.config.update(config))
  unless djinn.config[:__stop]
    yield djinn if block_given?
    if djinn.config[:__daemonize]
      djinn.start
    else
      djinn.run
    end
  else
    djinn.stop
  end
end