Class: Aruba::EventBus::NameResolver
- Inherits:
-
Object
- Object
- Aruba::EventBus::NameResolver
- Defined in:
- lib/aruba/event_bus/name_resolver.rb
Overview
Resolve name to Event name
Defined Under Namespace
Modules: ResolveHelpers Classes: ClassResolver, FailingResolver, StringResolver, SymbolResolver
Instance Method Summary collapse
-
#initialize(default_namespace) ⇒ NameResolver
constructor
A new instance of NameResolver.
- #transform(event_id) ⇒ Object
Constructor Details
#initialize(default_namespace) ⇒ NameResolver
Returns a new instance of NameResolver.
138 139 140 141 142 143 144 145 146 |
# File 'lib/aruba/event_bus/name_resolver.rb', line 138 def initialize(default_namespace) @default_namespace = default_namespace @resolvers = [] @resolvers << ClassResolver @resolvers << StringResolver @resolvers << SymbolResolver @resolvers << FailingResolver end |
Instance Method Details
#transform(event_id) ⇒ Object
148 149 150 151 152 153 154 155 |
# File 'lib/aruba/event_bus/name_resolver.rb', line 148 def transform(event_id) resolvers.find { |r| r.match? event_id }.new.transform(default_namespace, event_id) rescue StandardError => e types = @resolvers.map(&:supports).flatten.join(", ") = "Transforming \"#{event_id}\" into an event class failed." \ " Supported types are: #{types}. #{e.}." raise EventNameResolveError, , cause: e end |