Module: Inspec::ProfileContext::DomainSpecificLunacy

Defined in:
lib/inspec/profile_context.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create_dsl(profile_context) ⇒ Object



217
218
219
220
221
222
# File 'lib/inspec/profile_context.rb', line 217

def self.create_dsl(profile_context)
  Module.new do
    include DomainSpecificLunacy
    add_methods(profile_context)
  end
end

.included(mod) ⇒ Object



224
225
226
# File 'lib/inspec/profile_context.rb', line 224

def self.included(mod)
  mod.extend ClassMethods
end

Instance Method Details

#resource_class(profile_name, resource_name) ⇒ Object

Raises:



228
229
230
231
232
233
234
235
236
237
238
# File 'lib/inspec/profile_context.rb', line 228

def resource_class(profile_name, resource_name)
  inner_context = if profile_name == profile_context.profile_id
                    profile_context
                  else
                    profile_context.subcontext_by_name(profile_name)
                  end

  raise ProfileNotFound, "Cannot find profile named: #{profile_name}" if inner_context.nil?

  inner_context.resource_registry[resource_name]
end