Class: Anoubis::Output::Data
- Defined in:
- app/controllers/anoubis/output/data.rb
Overview
Output subclass that represents data for default index action
Instance Attribute Summary collapse
-
#count ⇒ String
The model’s row count.
-
#data ⇒ Array
Array of output data.
-
#fields ⇒ Array
Array of output fields.
-
#filter ⇒ Array
Array of filter fields.
-
#limit ⇒ Integer
Output limit fro returns rows.
-
#offset ⇒ Integer
Output offset for rows were returned.
-
#order ⇒ String
Returns order type current output data (‘asc’ or ‘desc’).
-
#sort ⇒ String
Returns order field for current output data.
-
#sortable ⇒ String
Returns name for manual table order.
Attributes inherited from Basic
#messages, #result, #tab, #title
Instance Method Summary collapse
-
#initialize ⇒ Data
constructor
Initializes output data.
-
#message1 ⇒ String
Generates output message based on self.result variable.
-
#to_h ⇒ Hash
Generates hash representation of output class.
Methods inherited from Basic
#hash_to_json, #message, #options_to_json
Constructor Details
#initialize ⇒ Data
Initializes output data. Generates default values.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/anoubis/output/data.rb', line 50 def initialize super self.data = nil self.fields = nil self.filter = nil self.count = 0 self.offset = 0 self.limit = 20 self.sort = nil self.order = '' self.sortable = nil end |
Instance Attribute Details
#count ⇒ String
Returns the model’s row count.
11 |
# File 'app/controllers/anoubis/output/data.rb', line 11 class_attribute :count |
#data ⇒ Array
Returns array of output data.
23 |
# File 'app/controllers/anoubis/output/data.rb', line 23 class_attribute :data |
#fields ⇒ Array
Returns array of output fields.
27 |
# File 'app/controllers/anoubis/output/data.rb', line 27 class_attribute :fields |
#filter ⇒ Array
Returns array of filter fields.
31 |
# File 'app/controllers/anoubis/output/data.rb', line 31 class_attribute :filter |
#limit ⇒ Integer
Returns output limit fro returns rows.
19 |
# File 'app/controllers/anoubis/output/data.rb', line 19 class_attribute :limit |
#offset ⇒ Integer
Returns output offset for rows were returned.
15 |
# File 'app/controllers/anoubis/output/data.rb', line 15 class_attribute :offset |
#order ⇒ String
Returns order type current output data (‘asc’ or ‘desc’).
41 |
# File 'app/controllers/anoubis/output/data.rb', line 41 class_attribute :order |
#sort ⇒ String
Returns order field for current output data.
36 |
# File 'app/controllers/anoubis/output/data.rb', line 36 class_attribute :sort |
#sortable ⇒ String
Returns name for manual table order
46 |
# File 'app/controllers/anoubis/output/data.rb', line 46 class_attribute :sortable |
Instance Method Details
#message1 ⇒ String
Generates output message based on self.result variable.
89 90 91 92 93 94 95 96 97 98 |
# File 'app/controllers/anoubis/output/data.rb', line 89 def case self.result when -1 return I18n.t('errors.invalid_login_parameters') when -2 return I18n.t('errors.invalid_login_or_password') else return super end end |
#to_h ⇒ Hash
Generates hash representation of output class
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/controllers/anoubis/output/data.rb', line 66 def to_h result = super.to_h return result if self.result != 0 result.merge!({ count: self.count, offset: self.offset, limit: self.limit }) if self.sort result[:sort] = self.sort result[:order] = self.order end result.merge!({ fields: self.fields}) if self.fields result.merge!({ filter: self.filter}) if self.filter result.merge!({ data: self.data}) if self.data result[:sortable] = self.sortable if self.sortable result end |