Class: CWM::WrapperWidget

Inherits:
AbstractWidget show all
Defined in:
library/cwm/src/lib/cwm/wrapper_widget.rb

Overview

Note:

it does not support some of common methods and helpers from abstract widget

Wrapper when combination of old hash based CWM definition needed to be used with new object based one. Useful e.g. when content is provided by other module like CWMFirewallInterfaces.CreateOpenFirewallWidget

Examples:

how to initialize object from firewall interface

::CWM::WrapperWidget.new("firewall",
  CWMFirewallInterfaces.CreateOpenFirewallWidget("services" => ["service:sshd", "service:ntp"])
)

Instance Attribute Summary

Attributes inherited from AbstractWidget

#widget_id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractWidget

#cleanup, #disable, #enable, #enabled?, #handle, #help, #init, #label, #opt, #store, #validate

Constructor Details

#initialize(content, id: nil) ⇒ WrapperWidget

Creates new instance with specified id and content

Parameters:

  • id (String)

    name of widget used as identified, have to be unique. It have to be same as real widget id in content, otherwise enable/disable won't work. If nil is used, it use default widget_id from class name.

  • content (CWM::WidgetHash)

    CWM hash definition



21
22
23
24
# File 'library/cwm/src/lib/cwm/wrapper_widget.rb', line 21

def initialize(content, id: nil)
  self.widget_id = id if id
  @content = content
end

Class Method Details

.widget_type=(_arg) ⇒ Object

not supported

Raises:

  • (RuntimeError)

    always when called



43
44
45
# File 'library/cwm/src/lib/cwm/wrapper_widget.rb', line 43

def self.widget_type=(_arg)
  raise "Not supported for WrapperWidget"
end

Instance Method Details

#cwm_definitionObject

returns given hash specification



27
28
29
# File 'library/cwm/src/lib/cwm/wrapper_widget.rb', line 27

def cwm_definition
  @content.merge("_cwm_key" => widget_id)
end

#handle_all_eventsObject



31
32
33
# File 'library/cwm/src/lib/cwm/wrapper_widget.rb', line 31

def handle_all_events
  @content["handle_events"].nil?
end

#handle_all_events=(_arg) ⇒ Object

not supported

Raises:

  • (RuntimeError)

    always when called



37
38
39
# File 'library/cwm/src/lib/cwm/wrapper_widget.rb', line 37

def handle_all_events=(_arg)
  raise "Not supported for WrapperWidget"
end