Module: Yast::Exportable

Included in:
Module
Defined in:
src/ruby/yast/exportable.rb

Overview

Provides ability to export functions and variables to Yast component system. The most important method is #publish

Defined Under Namespace

Modules: ExceptionReporter

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(mod) ⇒ Object

Extend by ExceptionReporter to allow exported module report last exception



63
64
65
# File 'src/ruby/yast/exportable.rb', line 63

def self.extended(mod)
  mod.send(:include, ExceptionReporter)
end

Instance Method Details

#publish(options) ⇒ Object

Note:

mandatory options are :type and :variable xor :function. Both together is not supported

Publishes function or variable to component system

Parameters:

  • options (Hash)

    specified parameters

Options Hash (options):

  • :type (String)

    specified Yast type that allows communication with type languages

  • :private (TrueClass, FalseClass) — default: false

    if specified then exported only in old testsuite environment after convert of testsuite all private publish call can be removed

  • :variable (Symbol)

    exported variable

  • :function (Symbol)

    exported function



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'src/ruby/yast/exportable.rb', line 38

def publish(options)
  raise "Missing signature" unless options[:type]
  # convert type to full specification
  type = options[:type].delete " \t"
  type.gsub!(/map([^<]|$)/, 'map<any,any>\\1')
  type.gsub!(/list([^<]|$)/, 'list<any>\\1')
  if options[:function]
    published_functions.push([options[:function], type])
  elsif options[:variable]
    published_variables.push([options[:variable], type])
    attr_accessor options[:variable]
  else
    raise "Missing publish kind"
  end
end

#published_functionsArray<Array(Symbol,String)>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns list of published functions.

Examples:

[
  [:doit, "void()"],
  [:is_odd, "boolean(integer)"]
]

Returns:

  • (Array<Array(Symbol,String)>)

    list of published functions



14
15
16
# File 'src/ruby/yast/exportable.rb', line 14

def published_functions
  @__published_functions ||= []
end

#published_variablesArray<Array(Symbol,String)>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns list of published variables.

Examples:

[
  [:answer, "integer"],
  [:having_fun, "boolean"]
]

Returns:

  • (Array<Array(Symbol,String)>)

    list of published variables



25
26
27
# File 'src/ruby/yast/exportable.rb', line 25

def published_variables
  @__published_variables ||= []
end