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

Defined in:
lib/inspec/profile_context.rb

Instance Method Summary collapse

Instance Method Details

#add_methods(profile_context) ⇒ Object



237
238
239
240
241
242
243
244
# File 'lib/inspec/profile_context.rb', line 237

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



246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/inspec/profile_context.rb', line 246

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