Module: FirmIndexer

Defined in:
lib/mas/firm_indexer.rb

Class Method Summary collapse

Class Method Details

.associated_firm_destroyed?(aggregate) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
# 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) ⇒ Object



13
14
15
16
17
18
19
# 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

.index_firm(firm) ⇒ Object Also known as: handle_firm_changed



3
4
5
6
7
8
9
# 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