Class: Smartest::HelperRegistry
- Inherits:
-
Object
- Object
- Smartest::HelperRegistry
- Includes:
- Enumerable
- Defined in:
- lib/smartest/helper_registry.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(helper_module) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize ⇒ HelperRegistry
constructor
A new instance of HelperRegistry.
- #to_a ⇒ Object
Constructor Details
#initialize ⇒ HelperRegistry
Returns a new instance of HelperRegistry.
13 14 15 |
# File 'lib/smartest/helper_registry.rb', line 13 def initialize @helper_modules = [] end |
Class Method Details
.validate!(helper_module) ⇒ Object
7 8 9 10 11 |
# File 'lib/smartest/helper_registry.rb', line 7 def self.validate!(helper_module) unless helper_module.is_a?(Module) && !helper_module.is_a?(Class) raise ArgumentError, "helper must be a module" end end |
Instance Method Details
#add(helper_module) ⇒ Object
17 18 19 20 21 |
# File 'lib/smartest/helper_registry.rb', line 17 def add(helper_module) self.class.validate!(helper_module) @helper_modules << helper_module unless @helper_modules.include?(helper_module) end |
#each(&block) ⇒ Object
23 24 25 |
# File 'lib/smartest/helper_registry.rb', line 23 def each(&block) @helper_modules.each(&block) end |
#to_a ⇒ Object
27 28 29 |
# File 'lib/smartest/helper_registry.rb', line 27 def to_a @helper_modules.dup end |