Class: QemuToolkit::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/qemu-toolkit/dsl.rb

Overview

A generic dsl class. You define a target keyword you want to associate with an object instance you also give during construction. The dsl will then react only to a call to TARGET, allowing to use a block to configure the object you give.

Inside the block, the following delegations are made:

foo 'some value'
# delegated to obj.foo= 'some value' if possible
# or then to obj.add_foo 'some_value'

Examples:

class Bar
  attr_accessor :name
  attr_accessor :test
end
bar = Bar.new

dsl = QemuToolkit::DSL::File.new
dsl.add_toplevel_target :foo, { |name| Bar.new(name) }
dsl.load_file(some_file)

# In this example, some_file would contain something like
foo('name') do
  test 'something'
end
bar.name # => 'name'
bar.test # => 'something'

Defined Under Namespace

Classes: File, Unit