Class: Jerakia::Launcher
- Inherits:
-
Object
- Object
- Jerakia::Launcher
- Defined in:
- lib/jerakia/launcher.rb
Instance Attribute Summary collapse
-
#answer ⇒ Object
readonly
Returns the value of attribute answer.
-
#policies ⇒ Object
readonly
Returns the value of attribute policies.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Launcher
constructor
A new instance of Launcher.
- #invoke_from_file ⇒ Object
- #policy_dir ⇒ Object
- #policy_exists?(policy) ⇒ Boolean
- #policy_files ⇒ Object
Constructor Details
#initialize ⇒ Launcher
Returns a new instance of Launcher.
13 14 15 16 17 18 19 20 |
# File 'lib/jerakia/launcher.rb', line 13 def initialize @policies = {} policy_files.each do |policy_file| policy = Jerakia::Dsl::Policy.evaluate_file(policy_file) raise Jerakia::PolicyError, "Policy #{policy.name} declared twice" if @policies[policy.name] @policies[policy.name] = policy end end |
Instance Attribute Details
#answer ⇒ Object (readonly)
Returns the value of attribute answer.
10 11 12 |
# File 'lib/jerakia/launcher.rb', line 10 def answer @answer end |
#policies ⇒ Object (readonly)
Returns the value of attribute policies.
11 12 13 |
# File 'lib/jerakia/launcher.rb', line 11 def policies @policies end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
9 10 11 |
# File 'lib/jerakia/launcher.rb', line 9 def request @request end |
Class Method Details
Instance Method Details
#invoke_from_file ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/jerakia/launcher.rb', line 38 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") policy = Jerakia::Dsl::Policy.evaluate_file(filename, request) policy.execute @answer = policy.answer end |
#policy_dir ⇒ Object
26 27 28 |
# File 'lib/jerakia/launcher.rb', line 26 def policy_dir Jerakia.config.policydir end |
#policy_exists?(policy) ⇒ Boolean
22 23 24 |
# File 'lib/jerakia/launcher.rb', line 22 def policy_exists?(policy) @policies.has_key?(policy.to_sym) end |
#policy_files ⇒ Object
30 31 32 |
# File 'lib/jerakia/launcher.rb', line 30 def policy_files Dir[File.join(policy_dir, '*.rb')] end |