Class: Anoubis::Etc::TabItem

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/anoubis/etc/tab_item.rb

Overview

Definitions of tab options.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ TabItem

Sets default parameters for tab

Parameters:

  • options (String) (defaults to: {})

    initial tab options

Options Hash (options):

  • :tab (String)

    tab identifier



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(options = {})
  self.tab = if options.key?(:tab) then options[:tab] else nil end
  self.sort = if options.key?(:sort) then options[:sort] else nil end
  self.order = ''
  if options.key? :order
    self.order = options[:order] if %w[asc desc].include?(options[:order])
  end
  self.title = if options.key?(:title) then options[:title] else self.tab.humanize end
  self.hint = if options.key?(:hint) then options[:hint] else '' end
  self.where = if options.key?(:where) then options[:where] else [] end
  self.export = if options.key?(:export) then options[:export] else true end
  self.filter = if options.key?(:filter) then options[:filter] else true end
  self.buttons = if options.key?(:buttons) then options[:buttons] else true end
end

Instance Attribute Details

#buttonsHash

Returns possibility for filter data for this tab (default: true)

Returns:

  • (Hash)

    tab’s filter possibility



39
# File 'app/controllers/anoubis/etc/tab_item.rb', line 39

class_attribute :buttons, default: {}

#exportBoolean

Returns possibility for export data for this tab (default: true)

Returns:

  • (Boolean)

    tab’s export possibility



29
# File 'app/controllers/anoubis/etc/tab_item.rb', line 29

class_attribute :export, default: true

#filterBoolean

Returns possibility for filter data for this tab (default: true)

Returns:

  • (Boolean)

    tab’s filter possibility



34
# File 'app/controllers/anoubis/etc/tab_item.rb', line 34

class_attribute :filter, default: true

#hintString

Returns tab hint

Returns:

  • (String)

    tab’s hint.



19
# File 'app/controllers/anoubis/etc/tab_item.rb', line 19

class_attribute :hint, default: ''

#orderString

Returns order type for this tab (‘asc’ or ‘desc’) (default: nil)

Returns:

  • (String)

    tab’s order type



49
# File 'app/controllers/anoubis/etc/tab_item.rb', line 49

class_attribute :order, default: nil

#sortString

Returns order field for this tab (default: nil)

Returns:

  • (String)

    tab’s order field



44
# File 'app/controllers/anoubis/etc/tab_item.rb', line 44

class_attribute :sort, default: nil

#tabString

Returns tab identifier

Returns:

  • (String)

    tab’s identifier.



9
# File 'app/controllers/anoubis/etc/tab_item.rb', line 9

class_attribute :tab, default: nil

#titleString

Returns tab title

Returns:

  • (String)

    tab’s title.



14
# File 'app/controllers/anoubis/etc/tab_item.rb', line 14

class_attribute :title, default: ''

#whereHash|Array

Returns tab where for selection from model.

Returns:

  • (Hash|Array)

    tab’s where



24
# File 'app/controllers/anoubis/etc/tab_item.rb', line 24

class_attribute :where, default: []

Instance Method Details

#to_hHash

Generates hash representation of all class parameters,

Returns:

  • (Hash)

    hash representation of all 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.buttons
  }
  if self.sort
    result[:sort] = self.sort
    result[:order] = self.order if self.order != ''
  end
  result
end