Class: Anoubis::Output::Frame

Inherits:
Basic
  • Object
show all
Defined in:
app/controllers/anoubis/output/frame.rb

Overview

Output subclass that represents data for frame action

Instance Attribute Summary collapse

Attributes inherited from Basic

#messages, #result, #tab, #title

Instance Method Summary collapse

Methods inherited from Basic

#hash_to_json, #message, #options_to_json

Constructor Details

#initializeFrame

Initializes menu output data. Generates default values.



28
29
30
31
32
33
34
35
36
# File 'app/controllers/anoubis/output/frame.rb', line 28

def initialize
  super
  self.title = ''
  self.short = ''
  self.mode = ''
  self.access = 'read'
  self.tab_items = []
  self.tabs = {}
end

Instance Attribute Details

#accessString

Returns the access to the menu element for current user (‘read’, ‘write’).

Returns:

  • (String)

    the access to the menu element for current user (‘read’, ‘write’).



16
# File 'app/controllers/anoubis/output/frame.rb', line 16

class_attribute :access

#modestring

Returns the identificator for current frame.

Returns:

  • (string)

    the identificator for current frame.



12
# File 'app/controllers/anoubis/output/frame.rb', line 12

class_attribute :mode

#shortstring

Returns the short title of current loaded frame.

Returns:

  • (string)

    the short title of current loaded frame.



8
# File 'app/controllers/anoubis/output/frame.rb', line 8

class_attribute :short

#tab_itemsArray

Returns the array of tab elements TabItem.

Returns:

  • (Array)

    the array of tab elements TabItem.



20
# File 'app/controllers/anoubis/output/frame.rb', line 20

class_attribute :tab_items

#tabsHash

Returns the hash of menu elements TabItem with ‘mode’ as a key.

Returns:

  • (Hash)

    the hash of menu elements TabItem with ‘mode’ as a key.



24
# File 'app/controllers/anoubis/output/frame.rb', line 24

class_attribute :tabs

Instance Method Details

#addTab(options) ⇒ Object

Adds new tab into tabs hash

Parameters:

  • options (Hash)

    the tab element options

Options Hash (options):

  • :key (String)

    The identifier of the tab element.

  • :title (String)

    The title of the tab element.

  • :hint (String)

    The hint for the tab element.



44
45
46
47
48
# File 'app/controllers/anoubis/output/frame.rb', line 44

def addTab(options)
  tab = TabItem.new options
  self.tab_items.push tab
  self.tabs[tab.tab.to_s.to_sym] = self.tab_items[self.tab_items.count-1]
end

#to_hHash

Generates hash representation of output class

Returns:

  • (Hash)

    hash representation of all data



53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/anoubis/output/frame.rb', line 53

def to_h
  result = super.to_h
  return result if self.result != 0
  result[:short] = self.short
  result[:mode] = self.mode
  result[:access] = self.access
  result[:tabs] = []
  self.tab_items.each { |item|
    result[:tabs].push(item.to_h) if item
  }
  result
end