Module: Artery::Model::InstanceMethods

Defined in:
lib/artery/model.rb

Instance Method Summary collapse

Instance Method Details

#artery_notify_message(action, extra_data = {}) ⇒ Object



75
76
77
78
79
80
81
# File 'lib/artery/model.rb', line 75

def artery_notify_message(action, extra_data = {})
  Artery.message_class.create! model: self.class.artery_model_name,
                               action: action,
                               #  version: self.class.artery_version, TODO:
                               data: { uuid: artery_uuid,
                                       updated_by_service: artery_updated_by_service }.merge(extra_data)
end

#artery_uuidObject



83
84
85
# File 'lib/artery/model.rb', line 83

def artery_uuid
  send(self.class.artery_uuid_attribute)
end

#to_artery(representation_name = nil) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/artery/model.rb', line 87

def to_artery(representation_name = nil)
  if representation_name && artery[:representations].key?(representation_name.to_sym)
    instance_eval(&artery[:representations][representation_name.to_sym])
  else
    instance_eval(&artery[:representations][:_default])
  end
end