Class: Anoubis::Output::Delete
- Defined in:
- app/controllers/anoubis/output/delete.rb
Overview
Output subclass that represents data for destroy action
Instance Attribute Summary collapse
-
#errors ⇒ Array<String>
Hash of errors.
-
#id ⇒ Number
Deleted id.
Attributes inherited from Basic
#messages, #result, #tab, #title
Instance Method Summary collapse
-
#initialize ⇒ Delete
constructor
Initializes menu output data.
-
#message ⇒ String
Returns customized message if Basic#result code equal -4.
-
#to_h ⇒ Hash
Generates hash representation of output class.
Methods inherited from Basic
#hash_to_json, #options_to_json
Constructor Details
#initialize ⇒ Delete
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
#errors ⇒ Array<String>
Returns hash of errors.
8 |
# File 'app/controllers/anoubis/output/delete.rb', line 8 class_attribute :errors, default: [] |
#id ⇒ Number
Returns deleted id.
12 |
# File 'app/controllers/anoubis/output/delete.rb', line 12 class_attribute :id, default: nil |
Instance Method Details
#message ⇒ String
Returns customized message if Basic#result code equal -4. Another way returns standard message
35 36 37 38 |
# File 'app/controllers/anoubis/output/delete.rb', line 35 def return I18n.t('errors.delete_error') if self.result == -4 return super end |
#to_h ⇒ Hash
Generates hash representation of output class
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 |