Class: Navgate
- Inherits:
-
Object
- Object
- Navgate
- Defined in:
- lib/navgate.rb
Defined Under Namespace
Classes: Builder
Instance Attribute Summary collapse
-
#controllers ⇒ Object
Returns the value of attribute controllers.
-
#ignoring ⇒ Object
Returns the value of attribute ignoring.
-
#navs ⇒ Object
Returns the value of attribute navs.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Navgate
constructor
A new instance of Navgate.
- #render_nav(selection, controller, options) ⇒ Object
- #select(selection, controller) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ Navgate
Returns a new instance of Navgate.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/navgate.rb', line 102 def initialize self.controllers = Rails.application.routes.routes.map do |route| route.defaults[:controller] end.uniq.compact yield(self) raise TypeError, "Expected Navgate:Builder or string" unless not_bad_type?(self.navs) if self.navs.is_a?(String) setup = YAML.load_file(self.navs) temp = [] setup.each do || temp.push(Navgate::Builder.new do || [:selection] = [1]['selection'].split(" ") [:default] = [1]['default'] || nill [:prefix] = [1]['prefix'] || nil [:controller] = [1]['controller'] || nil [:by_id] = [1]['by_id'] || nil [:css_class] = [1]['css_class'] || nil end ) end self.navs = temp end self.ignoring ||= [""] end |
Instance Attribute Details
#controllers ⇒ Object
Returns the value of attribute controllers.
100 101 102 |
# File 'lib/navgate.rb', line 100 def controllers @controllers end |
#ignoring ⇒ Object
Returns the value of attribute ignoring.
100 101 102 |
# File 'lib/navgate.rb', line 100 def ignoring @ignoring end |
#navs ⇒ Object
Returns the value of attribute navs.
100 101 102 |
# File 'lib/navgate.rb', line 100 def navs @navs end |
Instance Method Details
#render_nav(selection, controller, options) ⇒ Object
144 145 146 147 148 149 150 151 152 |
# File 'lib/navgate.rb', line 144 def render_nav selection, controller, split_controller = controller.split('/').last if ignoring.include?(split_controller) nil else nav = nav_cache(split_controller).render_it_with(,selection).html_safe nav end end |
#select(selection, controller) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/navgate.rb', line 131 def select selection, controller split_controller = controller.split('/').last if selection selection else if ignoring.include?(split_controller) nil else nav_cache(split_controller).default.to_s end end end |