Module: Legion::Extensions::Builder::Routes
Instance Attribute Summary collapse
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Instance Method Summary collapse
Methods included from Base
#const_defined_two?, #define_constant_two, #define_get, #find_files, #require_files
Instance Attribute Details
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
11 12 13 |
# File 'lib/legion/extensions/builders/routes.rb', line 11 def routes @routes end |
Instance Method Details
#build_routes ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/legion/extensions/builders/routes.rb', line 13 def build_routes @routes = {} return if lex_route_settings[:enabled] == false return if extension_disabled? @runners.each_value do |runner_info| runner_name = runner_info[:runner_name] runner_class = runner_info[:runner_class] runner_module = runner_info[:runner_module] next if runner_module.nil? next if excluded_runner?(runner_name) methods = runner_module.instance_methods(false) methods -= runner_module.skip_routes if runner_module.respond_to?(:skip_routes) methods -= excluded_functions_for methods.each do |function| route_path = "#{extension_name}/#{runner_name}/#{function}" defn = runner_module.respond_to?(:definition_for) ? runner_module.definition_for(function) : nil log.info "[Routes] auto-route registered: POST /api/extensions/#{extension_name}/runners/#{runner_name}/#{function}" @routes[route_path] = { lex_name: extension_name, runner_name: runner_name, function: function, component_type: 'runners', runner_class: runner_class, route_path: route_path, definition: defn } next unless defined?(Legion::API) && Legion::API.respond_to?(:router) Legion::API.router.register_extension_route( lex_name: extension_name, amqp_prefix: respond_to?(:amqp_prefix) ? amqp_prefix : "lex.#{extension_name.to_s.tr('_', '.')}", component_type: 'runners', component_name: runner_name, method_name: function.to_s, runner_class: runner_class, definition: defn ) end end end |