Module: VirtDisk::ExportMethods
- Included in:
- ClientHead, FileIo, PartitionType::DosPartition, PartitionType::GptPartition
- Defined in:
- lib/virt_disk/export_methods.rb
Overview
Every plug-in class must include this module, even if they don’t export any methods.
Utility module used by VirtDisk plug-ins, allowing them to export methods upstream.
Typically, VirtDisk plug-ins are linked in a chain - each plug-in communicating with the plug-in immediately upstream from it (where upstream is closer to the source of the data). The last downstream plug-in (the volume head) is the object accessed directly by the client.
This module enables upstream plug-ins to export methods, so they can be called directly from the volume head.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#delegate ⇒ Object
The module immediately upstream from this one.
-
#delegate=(obj) ⇒ Object
Set the module immediately upstream from this one.
-
#exported?(sym) ⇒ Boolean
-
true if sym is exported by this module’s class, false otherwise.
-
- #method_missing(sym, *args) ⇒ Object
- #respond_to_missing?(sym, include_all = false) ⇒ Boolean
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
69 70 71 72 |
# File 'lib/virt_disk/export_methods.rb', line 69 def method_missing(sym, *args) super unless respond_to_missing?(sym) @__delegate.send(sym, *args) end |
Class Method Details
.included(host_class) ⇒ Object
40 41 42 |
# File 'lib/virt_disk/export_methods.rb', line 40 def self.included(host_class) host_class.extend(ClassMethods) end |
Instance Method Details
#delegate ⇒ Object
The module immediately upstream from this one.
54 55 56 |
# File 'lib/virt_disk/export_methods.rb', line 54 def delegate @__delegate end |
#delegate=(obj) ⇒ Object
Set the module immediately upstream from this one.
47 48 49 |
# File 'lib/virt_disk/export_methods.rb', line 47 def delegate=(obj) @__delegate = obj end |
#exported?(sym) ⇒ Boolean
Returns - true if sym is exported by this module’s class, false otherwise.
60 61 62 |
# File 'lib/virt_disk/export_methods.rb', line 60 def exported?(sym) self.class.exported?(sym) end |
#respond_to_missing?(sym, include_all = false) ⇒ Boolean
64 65 66 67 |
# File 'lib/virt_disk/export_methods.rb', line 64 def respond_to_missing?(sym, include_all = false) return false unless @__delegate @__delegate.exported?(sym) || @__delegate.send(:respond_to_missing?, sym, include_all) end |