Class: UU::OS::GVC::MenuModel::MenuItem
- Inherits:
-
Object
- Object
- UU::OS::GVC::MenuModel::MenuItem
- Defined in:
- uu_os_gvc-0.28.16/lib/uu/os/gvc/menu_model.rb
Overview
Represenatation of a single menu item.
Instance Attribute Summary (collapse)
-
- (Object) action_uri
URI to use for the menu item navigation (UESURI, URL).
-
- (Object) disabled
Whether the item is disabled.
-
- (Object) target
Defines target window where the action URI will be opened - one of "CURRENT_WINDOW" (default), "NEW_WINDOW", "DIALOG_WINDOW".
-
- (Object) text
Item text.
Instance Method Summary (collapse)
-
- (MenuItem) initialize(data = nil)
constructor
Creates a new instance of MenuItem.
-
- (String) to_json(options = {})
Returns data representation as JSON String.
-
- (String) to_s
Returns data representation as String.
Constructor Details
- (MenuItem) initialize(data = nil)
Creates a new instance of MenuItem. Menu item with all fields set to nil is considered a separator.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/menu_model.rb', line 313 def initialize(data=nil) @attributes = {} if data.kind_of? String js = JSON.parse(data, :symbolize_names => true) if (!js.kind_of? Hash) raise ArgumentError.new("JSON String has bad format. The root element must be Hash but was #{js.class}.") end init_hash(js) elsif data.kind_of? Hash init_hash(deep_copy(data)) elsif data.kind_of? MenuItem init_hash(data.send(:to_h)) elsif !data.nil? raise ArgumentError.new("MenuItem data must be JSON String, Hash or MenuItem, but was #{data.class}.") end end |
Instance Attribute Details
- (Object) action_uri
URI to use for the menu item navigation (UESURI, URL). Can be also UESURI with VUC event, such as "ues:$this-art?:myevent".
281 282 283 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/menu_model.rb', line 281 def action_uri @action_uri end |
- (Object) disabled
Whether the item is disabled.
284 285 286 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/menu_model.rb', line 284 def disabled @disabled end |
- (Object) target
Defines target window where the action URI will be opened - one of "CURRENT_WINDOW" (default), "NEW_WINDOW", "DIALOG_WINDOW". For backward compatibility it's also possible to use older equivalents "SELF", "NEW" and "MODAL".
277 278 279 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/menu_model.rb', line 277 def target @target end |
- (Object) text
Item text.
272 273 274 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/menu_model.rb', line 272 def text @text end |
Instance Method Details
- (String) to_json(options = {})
Returns data representation as JSON String.
340 341 342 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/menu_model.rb', line 340 def to_json( = {}) @attributes.to_json() end |
- (String) to_s
Returns data representation as String.
354 355 356 |
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/menu_model.rb', line 354 def to_s to_json end |