Class: Jerakia::Launcher
- Inherits:
-
Object
- Object
- Jerakia::Launcher
- 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
Instance Attribute Summary collapse
-
#answer ⇒ Object
readonly
Returns the value of attribute answer.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Instance Method Summary collapse
-
#initialize(req, &block) ⇒ Launcher
constructor
A new instance of Launcher.
- #invoke_from_file ⇒ Object
- #policy(name, opts = {}, req = @request, &block) ⇒ Object
Constructor Details
#initialize(req, &block) ⇒ Launcher
Returns a new instance of Launcher.
8 9 10 11 |
# File 'lib/jerakia/launcher.rb', line 8 def initialize(req, &block) @request = req instance_eval &block end |
Instance Attribute Details
#answer ⇒ Object (readonly)
Returns the value of attribute answer.
7 8 9 |
# File 'lib/jerakia/launcher.rb', line 7 def answer @answer end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/jerakia/launcher.rb', line 6 def request @request end |
Instance Method Details
#invoke_from_file ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jerakia/launcher.rb', line 13 def invoke_from_file 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 = {}, req = @request, &block) ⇒ Object
25 26 27 28 29 |
# File 'lib/jerakia/launcher.rb', line 25 def policy(name, opts={}, req=@request, &block) policy = Jerakia::Policy.new(name, opts, req, &block) policy.fire! @answer = policy.answer end |