Class: Anoubis::Output::Edit

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

Overview

Output subclass that represents data for edit(new) action

Instance Attribute Summary collapse

Attributes inherited from Basic

#messages, #result, #tab

Instance Method Summary collapse

Methods inherited from Basic

#hash_to_json, #message, #options_to_json

Constructor Details

#initializeEdit

Initializes menu output data. Generates default values.



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

def initialize
  super
  self.title = ''
  self.fields = nil
  self.values = {}
  self.options = {}
  self.action = ''
end

Instance Attribute Details

#actionString

Returns additional action after update.

Returns:

  • (String)

    additional action after update



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

class_attribute :action

#fieldsArray

Returns array of output fields.

Returns:

  • (Array)

    array of output fields



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

class_attribute :fields

#optionsHash

Returns the hash of additional field options.

Returns:

  • (Hash)

    the hash of additional field options.



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

class_attribute :options, default: {}

#titleString

Returns the title of edit data.

Returns:

  • (String)

    the title of edit data



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

class_attribute :title

#valuesHash

Returns the hash of defined fields.

Returns:

  • (Hash)

    the hash of defined fields.



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

class_attribute :values, default: {}

Instance Method Details

#to_hHash

Generates hash representation of output class

Returns:

  • (Hash)

    hash representation of all data



41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/anoubis/output/edit.rb', line 41

def to_h
  result = super.to_h
  return result if self.result != 0
  result[:title] = self.title if self.title != ''
  result[:fields] = self.fields if self.fields
  result[:action] = self.action if self.action != ''
  result.merge!({
                    values: self.values,
                    options: self.options_to_json(self.options)
                })
  result
end