Module: ActivatedUI
- Defined in:
- lib/activated_ui.rb,
lib/activated_ui/helpers.rb,
lib/activated_ui/version.rb
Defined Under Namespace
Modules: Helpers
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
Instance Method Summary collapse
- #activate_ui_marked(*refs) ⇒ Object
- #activated_class(*refs) ⇒ Object
- #stored_activated_ui ⇒ Object
- #ui_activated?(*refs) ⇒ Boolean (also: #ui_activated)
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/activated_ui.rb', line 3 def self.included(base) # If the module is being included on a an Rails controller if defined?(ActionController::Base) && (base < ActionController::Base) base.helper_method :activated_class, :activate_ui_marked, :stored_activated_ui, :ui_activated, :ui_activated? def base.activate_ui_marked *refs params = refs.last.is_a?(Array) ? refs.pop : {} before_filter params do activate_ui_marked *refs end end if defined?(ActionView::Base) ActionView::Base.send :include, ActivatedUI::Helpers end end def base.activated_class value=nil @activated_class = value unless value.nil? @activated_class || 'active' end end |
Instance Method Details
#activate_ui_marked(*refs) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/activated_ui.rb', line 39 def activate_ui_marked *refs refs.each do |ref| stored_activated_ui << ref end stored_activated_ui end |
#activated_class(*refs) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/activated_ui.rb', line 31 def activated_class *refs if ui_activated? *refs self.class.activated_class else "" end end |
#stored_activated_ui ⇒ Object
46 47 48 |
# File 'lib/activated_ui.rb', line 46 def stored_activated_ui @stored_activated_ui ||= [] end |
#ui_activated?(*refs) ⇒ Boolean Also known as: ui_activated
50 51 52 53 54 55 56 |
# File 'lib/activated_ui.rb', line 50 def ui_activated? *refs all_match = true refs.each do |ref| all_match &&= stored_activated_ui.include?(ref) end all_match end |