Class: Dionysus::Producer::Registry::Registration::Topic
- Inherits:
-
Object
- Object
- Dionysus::Producer::Registry::Registration::Topic
- Defined in:
- lib/dionysus/producer/registry.rb
Defined Under Namespace
Classes: ModelRegistration
Instance Attribute Summary collapse
-
#models ⇒ Object
readonly
Returns the value of attribute models.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#producer ⇒ Object
Returns the value of attribute producer.
-
#serializer_klass ⇒ Object
readonly
Returns the value of attribute serializer_klass.
Instance Method Summary collapse
- #genesis_replica? ⇒ Boolean
- #genesis_to_s ⇒ Object
-
#initialize(namespace, name, serializer_klass, options = {}) ⇒ Topic
constructor
A new instance of Topic.
- #partition_key ⇒ Object
- #publish(model_klass, model_registrations_options = {}) ⇒ Object
- #publishes_model?(model_klass) ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(namespace, name, serializer_klass, options = {}) ⇒ Topic
Returns a new instance of Topic.
54 55 56 57 58 59 60 |
# File 'lib/dionysus/producer/registry.rb', line 54 def initialize(namespace, name, serializer_klass, = {}) @namespace = namespace @name = name @options = @serializer_klass = serializer_klass @models = [] end |
Instance Attribute Details
#models ⇒ Object (readonly)
Returns the value of attribute models.
50 51 52 |
# File 'lib/dionysus/producer/registry.rb', line 50 def models @models end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
50 51 52 |
# File 'lib/dionysus/producer/registry.rb', line 50 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
50 51 52 |
# File 'lib/dionysus/producer/registry.rb', line 50 def namespace @namespace end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
50 51 52 |
# File 'lib/dionysus/producer/registry.rb', line 50 def @options end |
#producer ⇒ Object
Returns the value of attribute producer.
52 53 54 |
# File 'lib/dionysus/producer/registry.rb', line 52 def producer @producer end |
#serializer_klass ⇒ Object (readonly)
Returns the value of attribute serializer_klass.
50 51 52 |
# File 'lib/dionysus/producer/registry.rb', line 50 def serializer_klass @serializer_klass end |
Instance Method Details
#genesis_replica? ⇒ Boolean
74 75 76 |
# File 'lib/dionysus/producer/registry.rb', line 74 def genesis_replica? .fetch(:genesis_replica, false) == true end |
#genesis_to_s ⇒ Object
66 67 68 |
# File 'lib/dionysus/producer/registry.rb', line 66 def genesis_to_s Dionysus::TopicName.new(namespace, "#{name}_#{GENESIS_SUFFIX}").to_s if genesis_replica? end |
#partition_key ⇒ Object
70 71 72 |
# File 'lib/dionysus/producer/registry.rb', line 70 def partition_key .fetch(:partition_key, nil) end |
#publish(model_klass, model_registrations_options = {}) ⇒ Object
78 79 80 |
# File 'lib/dionysus/producer/registry.rb', line 78 def publish(model_klass, = {}) @models << ModelRegistration.new(model_klass, ) end |
#publishes_model?(model_klass) ⇒ Boolean
82 83 84 |
# File 'lib/dionysus/producer/registry.rb', line 82 def publishes_model?(model_klass) models.any? { |registration| registration.model_klass == model_klass } end |