Class: QemuToolkit::DSL::Unit
- Inherits:
-
Object
- Object
- QemuToolkit::DSL::Unit
- Defined in:
- lib/qemu-toolkit/dsl.rb
Instance Method Summary collapse
-
#initialize(obj, &block) ⇒ Unit
constructor
A new instance of Unit.
- #method_missing(sym, *args, &block) ⇒ Object
- #respond_to?(sym) ⇒ Boolean
Constructor Details
#initialize(obj, &block) ⇒ Unit
Returns a new instance of Unit.
58 59 60 61 |
# File 'lib/qemu-toolkit/dsl.rb', line 58 def initialize(obj, &block) @object = obj instance_eval(&block) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/qemu-toolkit/dsl.rb', line 63 def method_missing(sym, *args, &block) delegate = find_delegate_method(sym, @object) return super unless delegate if delegate.arity == args.size delegate.call(*args, &block) else delegate.call(args, &block) end end |
Instance Method Details
#respond_to?(sym) ⇒ Boolean
73 74 75 |
# File 'lib/qemu-toolkit/dsl.rb', line 73 def respond_to?(sym) find_delegate_method(sym, @object) || super end |