Class: Jerakia::Launcher

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

Overview

Here we take a request object and read in the policy file which is evalulated in this instance

Direct Known Subclasses

Policy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(req) ⇒ Launcher

Returns a new instance of Launcher.



8
9
10
11
# File 'lib/jerakia/launcher.rb', line 8

def initialize(req)
  @@request = req
  invoke
end

Instance Attribute Details

#answerObject (readonly)

Returns the value of attribute answer.



7
8
9
# File 'lib/jerakia/launcher.rb', line 7

def answer
  @answer
end

#requestObject (readonly)

Returns the value of attribute request.



6
7
8
# File 'lib/jerakia/launcher.rb', line 6

def request
  @request
end

Instance Method Details

#invokeObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/jerakia/launcher.rb', line 13

def invoke
  policy_name=request.policy.to_s
  Jerakia.log.debug "Invoked lookup for #{@@request.key} using policy #{policy_name}"
  filename=File.join(Jerakia.config.policydir, "#{policy_name}.rb")
  begin
    policydata=Jerakia.filecache(filename)
  rescue Exception => e
    Jerakia.crit("Problem loading policy from #{filename}")
  end
  instance_eval policydata
end

#policy(name, opts = {}, &block) ⇒ Object



30
31
32
33
34
# File 'lib/jerakia/launcher.rb', line 30

def policy(name, opts={},  &block)
  policy = Jerakia::Policy.new(name, opts, &block)
  policy.fire!
  @answer = policy.answer
end