Class: GatherContent::Config::Tab

Inherits:
Object
  • Object
show all
Defined in:
lib/gather_content/config/tab.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label = "", name = "", hidden = false, elements = []) ⇒ Tab



6
7
8
9
10
11
# File 'lib/gather_content/config/tab.rb', line 6

def initialize(label = "", name = "", hidden = false, elements = [])
  self.label = label
  self.name = name
  self.hidden = hidden
  self.elements = elements
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



4
5
6
# File 'lib/gather_content/config/tab.rb', line 4

def elements
  @elements
end

#hiddenObject

Returns the value of attribute hidden.



4
5
6
# File 'lib/gather_content/config/tab.rb', line 4

def hidden
  @hidden
end

#labelObject

Returns the value of attribute label.



4
5
6
# File 'lib/gather_content/config/tab.rb', line 4

def label
  @label
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/gather_content/config/tab.rb', line 4

def name
  @name
end

Instance Method Details

#serialize(options = nil) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gather_content/config/tab.rb', line 13

def serialize(options = nil)
  raise ArgumentError, "name is required" unless name.present?
  raise ArgumentError, "label is required" unless label.present?

  {
    label: label,
    name: name,
    hidden: !!hidden,
    elements: elements.map{ |el| el.serialize(options) }
  }
end

#to_json(options = nil) ⇒ Object



25
26
27
# File 'lib/gather_content/config/tab.rb', line 25

def to_json(options = nil)
  serialize.to_json(options)
end