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.
149 150 151 152 153 154 155 156 157 |
# File 'lib/aruba/event_bus/name_resolver.rb', line 149 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
159 160 161 162 163 164 165 |
# File 'lib/aruba/event_bus/name_resolver.rb', line 159 def transform(event_id) resolvers.find { |r| r.match? event_id }.new.transform(default_namespace, event_id) rescue => e # rubocop:disable Metrics/LineLength raise EventNameResolveError, %(Transforming "#{event_id}" into an event class failed. Supported types are: #{@resolvers.map(&:supports).flatten.join(', ')}. #{e.}.\n\n#{e.backtrace.join("\n")}) # rubocop:enable Metrics/LineLength end |