Class: Lolita::Configuration::Tabs

Inherits:
Base show all
Includes:
Enumerable, ObservedArray
Defined in:
lib/lolita/configuration/tabs.rb

Overview

Lolita::Configuration::Tabs is container class that holds all tabs for each lolita instance. Also it has some useful methods.

Instance Attribute Summary collapse

Attributes inherited from Base

#component, #dbi

Instance Method Summary collapse

Methods included from ObservedArray

#<<, #[]=, #insert, #method_missing, #push

Methods included from Builder

#build, #builder, #builder=, #builder_default_name, #builder_default_options, #builder_default_state

Constructor Details

#initialize(dbp, *args, &block) ⇒ Tabs

Returns a new instance of Tabs.



13
14
15
16
17
18
# File 'lib/lolita/configuration/tabs.rb', line 13

def initialize dbp,*args,&block
  set_and_validate_dbp(dbp)
  set_default_attributes
  set_attributes(*args)
  self.instance_eval(&block) if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Lolita::ObservedArray

Instance Attribute Details

#excludedObject (readonly)

Returns the value of attribute excluded.



10
11
12
# File 'lib/lolita/configuration/tabs.rb', line 10

def excluded
  @excluded
end

#tab_typesObject

Returns the value of attribute tab_types.



11
12
13
# File 'lib/lolita/configuration/tabs.rb', line 11

def tab_types
  @tab_types
end

Instance Method Details

#associatedObject



49
50
51
# File 'lib/lolita/configuration/tabs.rb', line 49

def associated
  @tabs.select{|tab| !tab.dissociate}
end

#by_type(type) ⇒ Object



41
42
43
# File 'lib/lolita/configuration/tabs.rb', line 41

def by_type(type)
  @tabs.detect{|tab| tab.type == type.to_sym }
end

#defaultObject



57
58
59
# File 'lib/lolita/configuration/tabs.rb', line 57

def default
  tab_types.each{|type| tab(type.to_sym)}
end

#dissociatedObject



53
54
55
# File 'lib/lolita/configuration/tabs.rb', line 53

def dissociated
  @tabs.select{|tab| tab.dissociate}
end

#eachObject



20
21
22
23
# File 'lib/lolita/configuration/tabs.rb', line 20

def each
  create_content_tab if @tabs.empty?
  @tabs.each{|tab| yield tab }
end

#fieldsObject



37
38
39
# File 'lib/lolita/configuration/tabs.rb', line 37

def fields
  @tabs.map(&:fields).flatten
end

#namesObject



45
46
47
# File 'lib/lolita/configuration/tabs.rb', line 45

def names
  @tabs.map(&:name)
end

#tab(*args, &block) ⇒ Object



33
34
35
# File 'lib/lolita/configuration/tabs.rb', line 33

def tab *args,&block
  self << build_element(args && args[0],&block)
end

#tabs=(values) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/lolita/configuration/tabs.rb', line 25

def tabs=(values)
  if values.respond_to?(:each)
    values.each{|tab| self << tab}
  else
    raise ArgumentError, "#{values} must respond to each"
  end
end