Class: Tabulous::Dsl::Tabs

Inherits:
Object
  • Object
show all
Defined in:
lib/tabulous/dsl/tabs.rb

Class Method Summary collapse

Class Method Details

.method_missing(method, *args, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tabulous/dsl/tabs.rb', line 14

def method_missing(method, *args, &block)
  method_name = method.to_s
  if method_name =~ /^(.+)_subtab/
    if @parent_tab.nil?
      raise SubtabOutOfOrderError, "You cannot start a tabs declaration with a subtab: '#{method_name}'."
    end
    tab = Dsl::Tab.process($1, @parent_tab, &block)
  elsif method_name =~ /^(.+)_tab/
    tab = Dsl::Tab.process($1, nil, &block)
    @parent_tab = tab
  else
    raise TabNameError, "Incorrect tab name: '#{method_name}'.  Tab names must end with _tab or _subtab."
  end
  @tabset.add_tab(tab)
end

.process(&block) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/tabulous/dsl/tabs.rb', line 6

def process(&block)
  @tabset = Tabset.new
  @parent_tab = nil
  instance_exec(&block)
  check_for_errors!
  @tabset
end