Skip to content

Commit

Permalink
Merge pull request #15108 from Ladas/minor_inventory_collection_enhan…
Browse files Browse the repository at this point in the history
…cements

Minor inventory collection enhancements
  • Loading branch information
agrare authored May 16, 2017
2 parents fb930de + acaa987 commit edb1082
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models/manager_refresh/inventory_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ def data_collection_finalized?
data_collection_finalized
end

def supports_sti?
@supports_sti_cache ||= model_class.column_names.include?("type")
end

def <<(inventory_object)
unless data_index[inventory_object.manager_uuid]
data_index[inventory_object.manager_uuid] = inventory_object
Expand Down Expand Up @@ -476,6 +480,13 @@ def new_inventory_object(hash)
def build(hash)
hash = hash.merge(builder_params)
inventory_object = new_inventory_object(hash)

uuid = inventory_object.manager_uuid
# Each InventoryObject must be able to build an UUID, return nil if it can't
return nil if uuid.blank?
# Return existing InventoryObject if we have it
return data_index[uuid] if data_index[uuid]
# Store new InventoryObject and return it
push(inventory_object)
inventory_object
end
Expand Down

0 comments on commit edb1082

Please sign in to comment.