Class: Anoubis::Output::Delete

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

Overview

Output subclass that represents data for destroy action

Instance Attribute Summary collapse

Attributes inherited from Basic

#messages, #result, #tab, #title

Instance Method Summary collapse

Methods inherited from Basic

#hash_to_json, #options_to_json

Constructor Details

#initializeDelete

Initializes menu output data. Generates default values.



16
17
18
19
20
# File 'app/controllers/anoubis/output/delete.rb', line 16

def initialize
  super
  self.id = nil
  self.errors = []
end

Instance Attribute Details

#errorsArray<String>

Returns hash of errors.

Returns:

  • (Array<String>)

    hash of errors



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

class_attribute :errors, default: []

#idNumber

Returns deleted id.

Returns:

  • (Number)

    deleted id



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

class_attribute :id, default: nil

Instance Method Details

#messageString

Returns customized message if Basic#result code equal -4. Another way returns standard message

Returns:

  • (String)

    customized message



35
36
37
38
# File 'app/controllers/anoubis/output/delete.rb', line 35

def message
  return I18n.t('errors.delete_error') if self.result == -4
  return super
end

#to_hHash

Generates hash representation of output class

Returns:

  • (Hash)

    hash representation of all data



25
26
27
28
29
30
# File 'app/controllers/anoubis/output/delete.rb', line 25

def to_h
  result = super.to_h
  result[:id] = self.id if self.id
  result[:errors] = self.errors if self.errors.length > 0
  result
end