module Inspec::ProfileContext::DomainSpecificLunacy::ClassMethods

Public Instance Methods

add_methods(profile_context) click to toggle source
# File lib/inspec/profile_context.rb, line 240
def add_methods(profile_context)
  backend = profile_context.backend

  define_method(:profile_context) { profile_context }
  define_method(:inspec) { backend }

  add_registry_methods(profile_context)
end
add_registry_methods(profile_context) click to toggle source
# File lib/inspec/profile_context.rb, line 249
def add_registry_methods(profile_context)
  be = profile_context.backend
  bec = be.class

  registry = profile_context.resource_registry
  registry.each do |id, r|
    define_method(id) { |*args| r.new(be, id.to_s, *args) }

    next if be.respond_to?(id)

    bec.define_method(id) { |*args| r.new(be, id.to_s, *args) }
  end
end