Class: Anoubis::Output::Update

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

Overview

Output subclass that represents data for update or create 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

#initializeUpdate

Initializes menu output data. Generates default values.



20
21
22
23
24
25
26
# File 'app/controllers/anoubis/output/update.rb', line 20

def initialize
  super
  self.values = {}
  self.errors = []
  self.action = ''
  self.messages[:'-3'] = I18n.t('errors.update_error')
end

Instance Attribute Details

#actionString

Returns resulting post action.

Returns:

  • (String)

    resulting post action



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

class_attribute :action, default: ''

#errorsArray<String>

Returns hash of errors.

Returns:

  • (Array<String>)

    hash of errors



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

class_attribute :errors, default: []

#valuesHash

Returns the hash of defined fields.

Returns:

  • (Hash)

    the hash of defined fields.



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

class_attribute :values, default: {}

Instance Method Details

#to_hHash

Generates hash representation of output class

Returns:

  • (Hash)

    hash representation of all data



31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/anoubis/output/update.rb', line 31

def to_h
  result = super.to_h
  result[:errors] = self.errors if self.errors.length > 0
  return result if self.result != 0
  result.merge!({
                    values: self.values,
                    action: self.action
                })
  result
end