huginn/app/models/link.rb

12 lines
464 B
Ruby
Raw Permalink Normal View History

2014-01-09 14:26:46 -08:00
# A Link connects Agents in a directed Event flow from the `source` to the `receiver`.
2013-03-09 22:32:52 -08:00
class Link < ActiveRecord::Base
belongs_to :source, :class_name => "Agent", :inverse_of => :links_as_source
belongs_to :receiver, :class_name => "Agent", :inverse_of => :links_as_receiver
before_create :store_event_id_at_creation
def store_event_id_at_creation
self.event_id_at_creation = source.events.limit(1).reorder("id desc").pluck(:id).first || 0
end
2013-03-09 22:32:52 -08:00
end