class Tabulous::Dsl::Tab

Public Class Methods

a_subtab_is_active() click to toggle source
# File lib/tabulous/dsl/tab.rb, line 51
def a_subtab_is_active
  @tab.declared_to_have_subtabs = true
end
active_when(&block) click to toggle source
# File lib/tabulous/dsl/tab.rb, line 46
def active_when(&block)
  @called << :active_when
  instance_exec(&block)
end
enabled_when(val = nil, &block) click to toggle source
# File lib/tabulous/dsl/tab.rb, line 41
def enabled_when(val = nil, &block)
  @called << :enabled_when
  @tab.enabled_when = block_given? ? block : val
end
http_verb(val = nil, &block) click to toggle source
# File lib/tabulous/dsl/tab.rb, line 31
def http_verb(val = nil, &block)
  @called << :http_verb
  @tab.http_verb = block_given? ? block : val
end
in_action(action) click to toggle source
# File lib/tabulous/dsl/tab.rb, line 66
def in_action(action)
  in_actions(action)
end
in_actions(*actions) click to toggle source
# File lib/tabulous/dsl/tab.rb, line 55
def in_actions(*actions)
  @active_mediator = OpenStruct.new
  @active_mediator.this = self
  @active_mediator.actions = actions
  def @active_mediator.of_controller(controller)
    self.controller = controller
    self.this.send(:register_rule)
  end
  @active_mediator
end
method_missing(method, *args, &block) click to toggle source
# File lib/tabulous/dsl/tab.rb, line 70
def method_missing(method, *args, &block)
  raise UnknownDeclarationError, "Unknown declaration '#{method}'."
end
process(name, parent_tab, &block) click to toggle source
# File lib/tabulous/dsl/tab.rb, line 8
def process(name, parent_tab, &block)
  @tab = ::Tabulous::Tab.new
  @tab.name = name.to_s
  if parent_tab
    @tab.kind = :subtab
    @tab.parent = parent_tab
  end
  @called = []
  instance_exec(&block)
  check_for_errors!
  @tab
end
text(val = nil, &block) click to toggle source
# File lib/tabulous/dsl/tab.rb, line 21
def text(val = nil, &block)
  @called << :text
  @tab.text = block_given? ? block : val
end
visible_when(val = nil, &block) click to toggle source
# File lib/tabulous/dsl/tab.rb, line 36
def visible_when(val = nil, &block)
  @called << :visible_when
  @tab.visible_when = block_given? ? block : val
end

Private Class Methods

check_for_errors!() click to toggle source
# File lib/tabulous/dsl/tab.rb, line 76
def check_for_errors!
  [:text, :link_path, :visible_when, :enabled_when, :active_when].each do |advice|
    if !@called.include?(advice)
      raise MissingDeclarationError, "Missing '#{advice}' in tab #{@tab.name}."
    end
  end
end
register_rule() click to toggle source
# File lib/tabulous/dsl/tab.rb, line 84
def register_rule
  @tab.add_active_actions(@active_mediator.controller, @active_mediator.actions)
end