module Backends::Helpers::RunBeforeHelper::ClassMethods

Public Instance Methods

needs_authn?(name) click to toggle source
# File lib/backends/helpers/run_before_helper.rb, line 17
def needs_authn?(name)
  name.to_s.match(/^(compute_|network_|os_tpl_|resource_tpl_|storage_).+/)
end
run_before(names, method, is_authn = false) click to toggle source
# File lib/backends/helpers/run_before_helper.rb, line 5
def run_before(names, method, is_authn = false)
  names.each do |name|
    next if is_authn && !needs_authn?(name)

    m = instance_method(name)
    define_method(name) do |*args, &block|
      send(method.to_sym)
      m.bind(self).call(*args, &block)
    end
  end
end