Class: Caixanegra::UnitHelper
- Inherits:
-
Object
- Object
- Caixanegra::UnitHelper
- Defined in:
- lib/caixanegra/unit_helper.rb
Class Method Summary collapse
Class Method Details
.all_units ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/caixanegra/unit_helper.rb', line 22 def all_units units = {} Caixanegra.units.each do |unit| if unit.is_a? Array units[unit[1]] = unit[0] else units[unit.name.demodulize.underscore.to_sym] = unit end end units end |
.scoped_units(scope) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/caixanegra/unit_helper.rb', line 4 def scoped_units(scope) units = {} scopes = (scope || "").split(",").map(&:to_sym) Caixanegra.units.each do |unit| unit_scope = unit.is_a?(Array) ? unit[0].scope : unit.scope if unit_scope.nil? || unit_scope.any? { |checking_scope| scopes.include?(checking_scope) } if unit.is_a? Array units[unit[1]] = unit[0] else units[unit.name.demodulize.underscore.to_sym] = unit end end end units end |