Module: Artery::MessageModel

Extended by:
ActiveSupport::Concern
Included in:
ActiveRecord::Message, NoBrainer::Message
Defined in:
app/models/concerns/artery/message_model.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#previous_indexObject

Raises:

  • (NotImplementedError)


43
44
45
# File 'app/models/concerns/artery/message_model.rb', line 43

def previous_index
  raise NotImplementedError
end

#publish_to_artery(previous_index: self.previous_index) ⇒ Object



47
48
49
# File 'app/models/concerns/artery/message_model.rb', line 47

def publish_to_artery(previous_index: self.previous_index)
  Artery.publish route, to_artery.merge('_previous_index' => previous_index)
end

#routeObject



35
36
37
# File 'app/models/concerns/artery/message_model.rb', line 35

def route
  uri.to_route
end

#to_arteryObject



39
40
41
# File 'app/models/concerns/artery/message_model.rb', line 39

def to_artery
  data.merge('_index' => index)
end

#uriObject



26
27
28
# File 'app/models/concerns/artery/message_model.rb', line 26

def uri
  Artery::Routing.uri(model: model, action: action)
end

#uri=(uri) ⇒ Object



30
31
32
33
# File 'app/models/concerns/artery/message_model.rb', line 30

def uri=(uri)
  self.model   = uri.model
  self.action  = uri.action
end