Module: CornStarch::CornStarchHelper
- Extended by:
- ActionView::Context, ActionView::Helpers
- Defined in:
- app/helpers/corn_starch/corn_starch_helper.rb
Overview
CornStarch Helper
Instance Method Summary collapse
-
#class_mash(base, classes) ⇒ Object
Class Masher.
-
#icon_link_to(target, icon, text = nil, extra = nil) ⇒ Object
Icon Link.
-
#method_missing(name, *args, &block) ⇒ Object
Missing Method Handler.
-
#render_link_to(target, partial, text = nil, extra = nil) ⇒ Object
Render Link.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
Missing Method Handler
40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/corn_starch/corn_starch_helper.rb', line 40 def method_missing name, *args, &block # Handle Generic Tag if name.to_s =~ /(.*)_tag/ content_tag $1.to_sym, *args, &block # Default else super end end |
Instance Method Details
#class_mash(base, classes) ⇒ Object
Class Masher
29 30 31 32 33 34 35 36 37 |
# File 'app/helpers/corn_starch/corn_starch_helper.rb', line 29 def class_mash base, classes class_s = base if classes.respond_to? :each classes.each { |c| class_s += " #{base}-#{c}" } else class_s += " #{base}-#{classes}" end class_s end |
#icon_link_to(target, icon, text = nil, extra = nil) ⇒ Object
Icon Link
15 16 17 18 19 |
# File 'app/helpers/corn_starch/corn_starch_helper.rb', line 15 def icon_link_to target, icon, text = nil, extra = nil link_to target, extra do image_tag(icon) + (text ? ' ' + text : '') end end |
#render_link_to(target, partial, text = nil, extra = nil) ⇒ Object
Render Link
22 23 24 25 26 |
# File 'app/helpers/corn_starch/corn_starch_helper.rb', line 22 def render_link_to target, partial, text = nil, extra = nil link_to target, extra do render(partial) + (text ? ' ' + text : '') end end |