Class: Glib::Json::Traversal::Visitor
- Inherits:
-
Object
- Object
- Glib::Json::Traversal::Visitor
- Defined in:
- app/controllers/concerns/glib/json/traversal.rb
Instance Attribute Summary collapse
-
#forms ⇒ Object
readonly
Used in test crawler.
Instance Method Summary collapse
- #begin_page(spec) ⇒ Object
- #end_page(spec) ⇒ Object
- #fullPageForm(spec) ⇒ Object
-
#initialize ⇒ Visitor
constructor
A new instance of Visitor.
- #traverse_multiple(views, block) ⇒ Object
- #traverse_single(view, block) ⇒ Object
- #traverse_vertical_content(view, block) ⇒ Object
Constructor Details
#initialize ⇒ Visitor
Returns a new instance of Visitor.
38 39 40 |
# File 'app/controllers/concerns/glib/json/traversal.rb', line 38 def initialize @forms = [] end |
Instance Attribute Details
#forms ⇒ Object (readonly)
Used in test crawler
36 37 38 |
# File 'app/controllers/concerns/glib/json/traversal.rb', line 36 def forms @forms end |
Instance Method Details
#begin_page(spec) ⇒ Object
46 47 48 49 50 |
# File 'app/controllers/concerns/glib/json/traversal.rb', line 46 def begin_page(spec) if (form = fullPageForm(spec)) @forms << form end end |
#end_page(spec) ⇒ Object
52 53 54 55 56 |
# File 'app/controllers/concerns/glib/json/traversal.rb', line 52 def end_page(spec) if fullPageForm(spec) @forms.pop end end |
#fullPageForm(spec) ⇒ Object
42 43 44 |
# File 'app/controllers/concerns/glib/json/traversal.rb', line 42 def fullPageForm(spec) spec['fullPageForm'] end |
#traverse_multiple(views, block) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/concerns/glib/json/traversal.rb', line 58 def traverse_multiple(views, block) if views.is_a? Array views.each do |view| case view['view'] when 'panels/form-v1' @forms << view traverse_single view, block @forms.pop else traverse_single view, block end end end end |
#traverse_single(view, block) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'app/controllers/concerns/glib/json/traversal.rb', line 77 def traverse_single(view, block) block.call view # Generic view children traverse_multiple view['childViews'], block # Generic menu buttons traverse_multiple view['buttons'], block traverse_multiple view['childButtons'], block # Split panel traverse_vertical_content view['left'], block traverse_vertical_content view['center'], block traverse_vertical_content view['right'], block # List template traverse_multiple view['editButtons'], block traverse_multiple view['leftButtons'], block traverse_multiple view['rightButtons'], block # Select field traverse_vertical_content view['header'], block traverse_vertical_content view['footer'], block # Table row traverse_multiple view['cellViews'], block # Table/List if (sections = view['sections']).is_a? Array sections.each do |section| traverse_vertical_content section['header'], block traverse_multiple section['rows'], block traverse_vertical_content section['footer'], block end end end |
#traverse_vertical_content(view, block) ⇒ Object
73 74 75 |
# File 'app/controllers/concerns/glib/json/traversal.rb', line 73 def traverse_vertical_content(view, block) traverse_multiple view['childViews'], block if view end |