Class: Sourced::Message::Registry
- Inherits:
-
Object
- Object
- Sourced::Message::Registry
- Defined in:
- lib/sourced/message.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, klass) ⇒ Object
-
#initialize(message_class) ⇒ Registry
constructor
A new instance of Registry.
- #inspect ⇒ Object
Constructor Details
#initialize(message_class) ⇒ Registry
Returns a new instance of Registry.
71 72 73 74 |
# File 'lib/sourced/message.rb', line 71 def initialize() @message_class = @lookup = {} end |
Instance Method Details
#[](key) ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/sourced/message.rb', line 80 def [](key) klass = lookup[key] return klass if klass .subclasses.each do |c| klass = c.registry[key] return klass if klass end nil end |
#[]=(key, klass) ⇒ Object
76 77 78 |
# File 'lib/sourced/message.rb', line 76 def []=(key, klass) @lookup[key] = klass end |
#inspect ⇒ Object
91 92 93 |
# File 'lib/sourced/message.rb', line 91 def inspect %(<#{self.class}:#{object_id} #{lookup.size} keys, #{.subclasses.size} child registries>) end |