module FirmIndexer

Public Class Methods

associated_firm_destroyed?(aggregate) click to toggle source
# File lib/mas/firm_indexer.rb, line 21
def associated_firm_destroyed?(aggregate)
  firm = aggregate.firm
  return true if (firm.nil? || firm.destroyed?)
  !Firm.exists?(firm.id)
end
handle_aggregate_changed(aggregate) click to toggle source
# File lib/mas/firm_indexer.rb, line 13
def handle_aggregate_changed(aggregate)
  # This method may be invoked as part of a cascade delete, in which case
  # we should do nothing here. The firm change notification will handle
  # the change.
  return if associated_firm_destroyed?(aggregate)
  index_firm(aggregate.firm)
end
handle_firm_changed(firm)
Alias for: index_firm
index_firm(firm) click to toggle source
# File lib/mas/firm_indexer.rb, line 3
def index_firm(firm)
  if !firm.destroyed? && firm.publishable?
    store_firm(firm)
  else
    delete_firm(firm)
  end
end
Also aliased as: handle_firm_changed

Private Class Methods

delete_firm(firm) click to toggle source
# File lib/mas/firm_indexer.rb, line 33
def delete_firm(firm)
  FirmRepository.new.delete(firm.id)
end
store_firm(firm) click to toggle source
# File lib/mas/firm_indexer.rb, line 29
def store_firm(firm)
  FirmRepository.new.store(firm)
end