Class: Slackify::Handlers::Factory
- Inherits:
-
Object
- Object
- Slackify::Handlers::Factory
- Defined in:
- lib/slackify/handlers/factory.rb
Overview
Creates the handler structs
Class Method Summary collapse
Class Method Details
.for(configuration) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/slackify/handlers/factory.rb', line 7 def self.for(configuration) Validator.verify_handler_integrity(configuration) handler = OpenStruct.new handler.name = configuration.keys.first handler.commands = [] configuration[handler.name]['commands']&.each do |command| built_command = OpenStruct.new built_command.regex = command['regex'] built_command.handler = handler.name.camelize.constantize.method(command['action']) built_command.description = command['description'] built_command.parameters = command['parameters'] built_command.base_command = command['base_command'] handler.commands << built_command.freeze end handler.commands.freeze handler.freeze end |