Class: Tabulous::Dsl::Tab
- Inherits:
-
Object
- Object
- Tabulous::Dsl::Tab
- Defined in:
- lib/tabulous/dsl/tab.rb
Class Method Summary collapse
- .a_subtab_is_active ⇒ Object
- .active_when(&block) ⇒ Object
- .enabled_when(val = nil, &block) ⇒ Object
- .http_verb(val = nil, &block) ⇒ Object
- .in_action(action) ⇒ Object
- .in_actions(*actions) ⇒ Object
- .link_path(val = nil, &block) ⇒ Object
- .method_missing(method, *args, &block) ⇒ Object
- .of_controller(controller) ⇒ Object
- .process(name, parent_tab, &block) ⇒ Object
- .text(val = nil, &block) ⇒ Object
- .visible_when(val = nil, &block) ⇒ Object
Class Method Details
.a_subtab_is_active ⇒ Object
51 52 53 |
# File 'lib/tabulous/dsl/tab.rb', line 51 def a_subtab_is_active @tab.declared_to_have_subtabs = true end |
.active_when(&block) ⇒ Object
46 47 48 49 |
# File 'lib/tabulous/dsl/tab.rb', line 46 def active_when(&block) @called << :active_when instance_exec(&block) end |
.enabled_when(val = nil, &block) ⇒ Object
41 42 43 44 |
# 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) ⇒ Object
31 32 33 34 |
# 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) ⇒ Object
66 67 68 |
# File 'lib/tabulous/dsl/tab.rb', line 66 def in_action(action) in_actions(action) end |
.in_actions(*actions) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# 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 |
.link_path(val = nil, &block) ⇒ Object
26 27 28 29 |
# File 'lib/tabulous/dsl/tab.rb', line 26 def link_path(val = nil, &block) @called << :link_path @tab.link_path = block_given? ? block : val end |
.method_missing(method, *args, &block) ⇒ Object
70 71 72 |
# File 'lib/tabulous/dsl/tab.rb', line 70 def method_missing(method, *args, &block) raise UnknownDeclarationError, "Unknown declaration '#{method}'." end |
.of_controller(controller) ⇒ Object
59 60 61 62 |
# File 'lib/tabulous/dsl/tab.rb', line 59 def @active_mediator.of_controller(controller) self.controller = controller self.this.send(:register_rule) end |
.process(name, parent_tab, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# 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) ⇒ Object
21 22 23 24 |
# 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) ⇒ Object
36 37 38 39 |
# 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 |