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 Classes: ExportData

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(mod) ⇒ Object

Extend by ExceptionReporter to allow exported module report last exception



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

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

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



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

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

#published_functionsObject

list of published functions



18
19
20
# File 'src/ruby/yast/exportable.rb', line 18

def published_functions
  @__published_functions ||= {}
end

#published_variablesObject

list of published variables



23
24
25
# File 'src/ruby/yast/exportable.rb', line 23

def published_variables
  @__published_variables ||= {}
end