Class: Dionysus::Producer::Registry::Registration::Topic

Inherits:
Object
  • Object
show all
Defined in:
lib/dionysus/producer/registry.rb

Defined Under Namespace

Classes: ModelRegistration

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @namespace = namespace
  @name = name
  @options = options
  @serializer_klass = serializer_klass
  @models = []
end

Instance Attribute Details

#modelsObject (readonly)

Returns the value of attribute models.



50
51
52
# File 'lib/dionysus/producer/registry.rb', line 50

def models
  @models
end

#nameObject (readonly)

Returns the value of attribute name.



50
51
52
# File 'lib/dionysus/producer/registry.rb', line 50

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



50
51
52
# File 'lib/dionysus/producer/registry.rb', line 50

def namespace
  @namespace
end

#optionsObject (readonly)

Returns the value of attribute options.



50
51
52
# File 'lib/dionysus/producer/registry.rb', line 50

def options
  @options
end

#producerObject

Returns the value of attribute producer.



52
53
54
# File 'lib/dionysus/producer/registry.rb', line 52

def producer
  @producer
end

#serializer_klassObject (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

Returns:

  • (Boolean)


74
75
76
# File 'lib/dionysus/producer/registry.rb', line 74

def genesis_replica?
  options.fetch(:genesis_replica, false) == true
end

#genesis_to_sObject



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_keyObject



70
71
72
# File 'lib/dionysus/producer/registry.rb', line 70

def partition_key
  options.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, model_registrations_options = {})
  @models << ModelRegistration.new(model_klass, model_registrations_options)
end

#publishes_model?(model_klass) ⇒ Boolean

Returns:

  • (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

#to_sObject



62
63
64
# File 'lib/dionysus/producer/registry.rb', line 62

def to_s
  Dionysus::TopicName.new(namespace, name).to_s
end