Module: VirtDisk::ExportMethods::ClassMethods

Defined in:
lib/virt_disk/export_methods.rb

Instance Method Summary collapse

Instance Method Details

#export(*syms) ⇒ Object

Export one or more methods, making them callable from the volume head.

Parameters:

  • syms (Symbol)

    the names of one or more methods to be exported.

Raises:

  • (RuntimeError)

    if any of the methods aren’t defined in the class.



18
19
20
21
22
23
24
25
26
# File 'lib/virt_disk/export_methods.rb', line 18

def export(*syms)
  syms.each do |s|
    sym = s.to_sym
    raise "Method not defined in class: #{sym}" unless method_defined?(sym)
    return nil if exports.include?(sym)
    exports << sym
  end
  nil
end

#exported?(sym) ⇒ Boolean

Returns - true if sym is exported by this class, false otherwise.

Parameters:

  • sym (Symbol)

Returns:

  • (Boolean)
    • true if sym is exported by this class, false otherwise.



35
36
37
# File 'lib/virt_disk/export_methods.rb', line 35

def exported?(sym)
  exports.include?(sym.to_sym)
end

#exportsArray<Symbol>

Returns array of exported methods.

Returns:

  • (Array<Symbol>)

    array of exported methods.



29
30
31
# File 'lib/virt_disk/export_methods.rb', line 29

def exports
  @__exported_methods ||= []
end