Class: Anoubis::Etc::TabItem
- Inherits:
-
Object
- Object
- Anoubis::Etc::TabItem
- Defined in:
- app/controllers/anoubis/etc/tab_item.rb
Overview
Definitions of tab options.
Instance Attribute Summary collapse
-
#buttons ⇒ Hash
Returns possibility for filter data for this tab (default: true).
-
#export ⇒ Boolean
Returns possibility for export data for this tab (default: true).
-
#filter ⇒ Boolean
Returns possibility for filter data for this tab (default: true).
-
#hint ⇒ String
Returns tab hint.
-
#order ⇒ String
Returns order type for this tab (‘asc’ or ‘desc’) (default: nil).
-
#sort ⇒ String
Returns order field for this tab (default: nil).
-
#tab ⇒ String
Returns tab identifier.
-
#title ⇒ String
Returns tab title.
-
#where ⇒ Hash|Array
Returns tab where for selection from model.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ TabItem
constructor
Sets default parameters for tab.
-
#to_h ⇒ Hash
Generates hash representation of all class parameters,.
Constructor Details
#initialize(options = {}) ⇒ TabItem
Sets default parameters for tab
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/anoubis/etc/tab_item.rb', line 55 def initialize( = {}) self.tab = if .key?(:tab) then [:tab] else nil end self.sort = if .key?(:sort) then [:sort] else nil end self.order = '' if .key? :order self.order = [:order] if %w[asc desc].include?([:order]) end self.title = if .key?(:title) then [:title] else self.tab.humanize end self.hint = if .key?(:hint) then [:hint] else '' end self.where = if .key?(:where) then [:where] else [] end self.export = if .key?(:export) then [:export] else true end self.filter = if .key?(:filter) then [:filter] else true end self. = if .key?(:buttons) then [:buttons] else true end end |
Instance Attribute Details
#buttons ⇒ Hash
Returns possibility for filter data for this tab (default: true)
39 |
# File 'app/controllers/anoubis/etc/tab_item.rb', line 39 class_attribute :buttons, default: {} |
#export ⇒ Boolean
Returns possibility for export data for this tab (default: true)
29 |
# File 'app/controllers/anoubis/etc/tab_item.rb', line 29 class_attribute :export, default: true |
#filter ⇒ Boolean
Returns possibility for filter data for this tab (default: true)
34 |
# File 'app/controllers/anoubis/etc/tab_item.rb', line 34 class_attribute :filter, default: true |
#hint ⇒ String
Returns tab hint
19 |
# File 'app/controllers/anoubis/etc/tab_item.rb', line 19 class_attribute :hint, default: '' |
#order ⇒ String
Returns order type for this tab (‘asc’ or ‘desc’) (default: nil)
49 |
# File 'app/controllers/anoubis/etc/tab_item.rb', line 49 class_attribute :order, default: nil |
#sort ⇒ String
Returns order field for this tab (default: nil)
44 |
# File 'app/controllers/anoubis/etc/tab_item.rb', line 44 class_attribute :sort, default: nil |
#tab ⇒ String
Returns tab identifier
9 |
# File 'app/controllers/anoubis/etc/tab_item.rb', line 9 class_attribute :tab, default: nil |
#title ⇒ String
Returns tab title
14 |
# File 'app/controllers/anoubis/etc/tab_item.rb', line 14 class_attribute :title, default: '' |
#where ⇒ Hash|Array
Returns tab where for selection from model.
24 |
# File 'app/controllers/anoubis/etc/tab_item.rb', line 24 class_attribute :where, default: [] |
Instance Method Details
#to_h ⇒ Hash
Generates hash representation of all class parameters,
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/anoubis/etc/tab_item.rb', line 73 def to_h result = { tab: self.tab, title: self.title, hint: self.hint, where: self.where, export: self.export, filter: self.filter, buttons: self. } if self.sort result[:sort] = self.sort result[:order] = self.order if self.order != '' end result end |