Module: Current
- Defined in:
- lib/current.rb
Instance Method Summary collapse
- #action_is?(*attrs) ⇒ Boolean
- #active_if?(condition) ⇒ Boolean
- #controller_action_is?(c, a) ⇒ Boolean
- #controller_is?(*attrs) ⇒ Boolean
- #nav_link_to(text, path, condition, options = {}) ⇒ Object
- #partial_is?(param) ⇒ Boolean
Instance Method Details
#action_is?(*attrs) ⇒ Boolean
7 8 9 |
# File 'lib/current.rb', line 7 def action_is?(*attrs) attrs.map{|attr| attr.to_s}.include?(action_name) end |
#active_if?(condition) ⇒ Boolean
19 20 21 |
# File 'lib/current.rb', line 19 def active_if?(condition) condition ? "active" : "inactive" end |
#controller_action_is?(c, a) ⇒ Boolean
15 16 17 |
# File 'lib/current.rb', line 15 def controller_action_is?(c,a) controller_is?(c) && action_is?(a) end |
#controller_is?(*attrs) ⇒ Boolean
3 4 5 |
# File 'lib/current.rb', line 3 def controller_is?(*attrs) attrs.collect{|attr| attr.to_s}.include?(controller_name) end |
#nav_link_to(text, path, condition, options = {}) ⇒ Object
23 24 25 26 27 |
# File 'lib/current.rb', line 23 def nav_link_to(text,path,condition, ={}) klass = active_if?(condition) + " #{[:class]}" linktext = condition ? "#{text}" : text link_to(raw(linktext), path, .merge(:class => klass.strip)) end |
#partial_is?(param) ⇒ Boolean
11 12 13 |
# File 'lib/current.rb', line 11 def partial_is?(param) param == params[:partial] end |