class Jerakia::Lookup
Attributes
datasource[RW]
lookuptype[R]
name[R]
output_filters[R]
pluginfactory[R]
proceed[RW]
request[RW]
scope_object[R]
valid[RW]
Public Class Methods
new(name, opts, req, scope)
click to toggle source
# File lib/jerakia/lookup.rb, line 18 def initialize(name, opts, req, scope) @name = name @request = req @valid = true @scope_object = scope @output_filters = [] @proceed = true @pluginfactory = Jerakia::Lookup::PluginFactory.new # Validate options passed to the lookup # valid_opts = [:use] opts.keys.each do |opt_key| unless valid_opts.include?(opt_key) raise Jerakia::PolicyError, "Unknown option #{opt_key} for lookup #{name}" end end if opts[:use] Array(opts[:use]).flatten.each do |plugin| plugin_load(plugin) end end end
Public Instance Methods
confine(key = nil, match)
click to toggle source
# File lib/jerakia/lookup.rb, line 107 def confine(key = nil, match) if key invalidate if get_matches(key, match).empty? else invalidate end end
continue()
click to toggle source
lookup function: continue
Will cause Jerakia
to continue to the next lookup in the policy which is the default behaviour
# File lib/jerakia/lookup.rb, line 88 def continue @proceed = true end
exclude(key = nil, match)
click to toggle source
# File lib/jerakia/lookup.rb, line 115 def exclude(key = nil, match) if key invalidate unless get_matches(key, match).empty? end end
get_matches(key, match)
click to toggle source
# File lib/jerakia/lookup.rb, line 103 def get_matches(key, match) matches = Array(match).select { |m| key[Regexp.new(m)] == key } end
invalidate()
click to toggle source
lookup function: invalidate
Setting invalidate will mean this lookup will be skipped in the policy
# File lib/jerakia/lookup.rb, line 95 def invalidate @valid = false end
output_filter(name, opts = {})
click to toggle source
# File lib/jerakia/lookup.rb, line 64 def output_filter(name, opts = {}) @output_filters << { :name => name, :opts => opts } end
plugin()
click to toggle source
# File lib/jerakia/lookup.rb, line 56 def plugin pluginfactory end
plugin_config(plugin)
click to toggle source
Retrieve plugin specific configuration from the global configuration file gets passed to the plugin instance upon initilization.
# File lib/jerakia/lookup.rb, line 47 def plugin_config(plugin) Jerakia::Lookup::PluginConfig.new(plugin) end
plugin_load(plugin)
click to toggle source
# File lib/jerakia/lookup.rb, line 51 def plugin_load(plugin) Jerakia.log.debug("Loading plugin #{plugin}") pluginfactory.register(plugin, Jerakia::Lookup::Plugin.new(self, plugin_config(plugin))) end
proceed?()
click to toggle source
# File lib/jerakia/lookup.rb, line 68 def proceed? proceed end
scope()
click to toggle source
# File lib/jerakia/lookup.rb, line 60 def scope scope_object.value end
stop()
click to toggle source
lookup function: stop
Enabling stop sets @proceed to false, which will cause Jerakia
not to load any more lookups in the policy if this lookup is deemed as valid. If the lookup is invalidated than Jerakia
will progress to the next lookup. This is useful in conjuction with the confine plugin where we want to segregate some lookups but not worry about excluding from later lookups
# File lib/jerakia/lookup.rb, line 80 def stop @proceed = false end
valid?()
click to toggle source
# File lib/jerakia/lookup.rb, line 99 def valid? valid end