Class: Upkeep::Subscriptions::Registrar
- Inherits:
-
Object
- Object
- Upkeep::Subscriptions::Registrar
- Defined in:
- lib/upkeep/subscriptions/registrar.rb
Defined Under Namespace
Classes: Registration
Instance Method Summary collapse
-
#initialize(store:, shape_cache: ShapeCache.new) ⇒ Registrar
constructor
A new instance of Registrar.
- #register(identity:, decision:, recorder:, metadata: {}, signature: nil) ⇒ Object
Constructor Details
#initialize(store:, shape_cache: ShapeCache.new) ⇒ Registrar
Returns a new instance of Registrar.
10 11 12 13 |
# File 'lib/upkeep/subscriptions/registrar.rb', line 10 def initialize(store:, shape_cache: ShapeCache.new) @store = store @shape_cache = shape_cache end |
Instance Method Details
#register(identity:, decision:, recorder:, metadata: {}, signature: nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/upkeep/subscriptions/registrar.rb', line 15 def register(identity:, decision:, recorder:, metadata: {}, signature: nil) shape = shape_cache.resolve(recorder: recorder, decision: decision, signature: signature) subscription = store.register( subscriber_id: identity.subscriber_id, recorder: recorder, metadata: .merge( shared_stream_names: shape.shared_stream_names, subscription_shape_key: shape.key, subscription_shape_cache: shape.cache_state ).compact, entries: shape.entries ) Registration.new(identity, decision, subscription, shape) end |