Sha256: 601e9507261399d6fe6fa7d1efd47fe43f19bbc4386792f95451e66c53002774
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module MiniCamel class Environment include Virtus.value_object values do attribute :route_builders, Array, default: [] attribute :routes, Array, default: [] attribute :finalized, Boolean, default: false attribute :finalizer_class, Class attribute :error_handler, Object end def dispatch_route(route_name, options = {}) with_data = options[:with_data] || Dto.new RouteDispatcher.new(route: route_name, with_data: with_data, env: self).dispatch end def register_route_builder(*builders) @route_builders += builders self end def register_error_handler(handler) @error_handler = handler self end def add_route(route) routes << route end def finalize finalizer_class.new(env: self).finalize self end def finalized! @finalized = true end # @internal def call_route(route_name, exchange) if route = routes_by_name[route_name] route.call(exchange) else raise UnknownRouteError, route_name end end def finalizer_class @finalizer_class ||= RouteFinalizer end def error_handler @error_handler ||= DefaultErrorHandler.new end private def routes_by_name @routes_by_name ||= routes.index_by(&:route_name) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mini_camel-0.5.8 | lib/mini_camel/environment.rb |