Module: Inspec::ProfileContext::DomainSpecificLunacy::ClassMethods

Defined in:
lib/inspec/profile_context.rb

Instance Method Summary collapse

Instance Method Details

#add_methods(profile_context) ⇒ Object



241
242
243
244
245
246
247
248
# File 'lib/inspec/profile_context.rb', line 241

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) ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/inspec/profile_context.rb', line 250

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