Class: Lolita::Configuration::Tabs
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
Instance Method Summary
collapse
Methods included from Builder
#build, #builder_options, #default_builder, #get_builder
#<<, #[]=, #insert, #method_missing, #push
Constructor Details
#initialize(dbi, *args, &block) ⇒ Tabs
Returns a new instance of Tabs.
13
14
15
16
17
18
19
|
# File 'lib/lolita/configuration/tabs.rb', line 13
def initialize dbi,*args,&block
@dbi=dbi
@tabs=[]
@excluded=[]
self.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
Returns the value of attribute dbi.
12
13
14
|
# File 'lib/lolita/configuration/tabs.rb', line 12
def dbi
@dbi
end
|
Returns the value of attribute excluded.
12
13
14
|
# File 'lib/lolita/configuration/tabs.rb', line 12
def excluded
@excluded
end
|
Instance Method Details
#by_type(type) ⇒ Object
49
50
51
|
# File 'lib/lolita/configuration/tabs.rb', line 49
def by_type(type)
@tabs.detect{|tab| tab.type==type.to_sym}
end
|
31
32
33
|
# File 'lib/lolita/configuration/tabs.rb', line 31
def clear
@tabs=[]
end
|
#default(*args) ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/lolita/configuration/tabs.rb', line 61
def default *args
tab_types=if args
args
else
default_tab_types
end
tab_types.each{|type|
self<<Lolita::Configuration::Tab.add(@dbi,type.to_sym)
}
end
|
#default=(values) ⇒ Object
57
58
59
|
# File 'lib/lolita/configuration/tabs.rb', line 57
def default=(values)
default(values)
end
|
21
22
23
24
25
26
27
28
29
|
# File 'lib/lolita/configuration/tabs.rb', line 21
def each
if @tabs.empty?
create_content_tab
end
@tabs.each{|tab|
yield tab
}
end
|
#exclude(*args) ⇒ Object
72
73
74
75
76
77
78
|
# File 'lib/lolita/configuration/tabs.rb', line 72
def exclude *args
@excluded=if args && args.include?(:all)
default_tab_types
else
args
end
end
|
#exclude=(values) ⇒ Object
53
54
55
|
# File 'lib/lolita/configuration/tabs.rb', line 53
def exclude=(values)
exclude(values)
end
|
80
81
82
|
# File 'lib/lolita/configuration/tabs.rb', line 80
def names
@tabs.map(&:name)
end
|
#set_attributes(*args) ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'lib/lolita/configuration/tabs.rb', line 84
def set_attributes *args
if args
attributes=args.
attributes.each{|attribute,values|
self.send(:"#{attribute}=",values)
}
end
end
|
#tab(*args, &block) ⇒ Object
45
46
47
|
# File 'lib/lolita/configuration/tabs.rb', line 45
def tab *args,&block
self<<Lolita::Configuration::Tab.add(@dbi,*args,&block)
end
|
#tabs=(values) ⇒ Object
35
36
37
38
39
40
41
42
43
|
# File 'lib/lolita/configuration/tabs.rb', line 35
def tabs=(values)
if values.respond_to?(:each)
values.each{|tab|
self<<tab
}
else
raise ArgumentError, "#{values.class} did not responded to :each."
end
end
|