Skip to content

Commit

Permalink
Rename ApplicationRecordLite to ApplicationRecordReference
Browse files Browse the repository at this point in the history
Rename ApplicationRecordLite to ApplicationRecordReference, as
it shows the purpose much better.
  • Loading branch information
Ladas committed Feb 23, 2017
1 parent 3d976da commit 19e7dcc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module ManagerRefresh
class ApplicationRecordLite
class ApplicationRecordReference
attr_reader :base_class_name, :id

# ApplicationRecord is very bloaty in memory, so this class server for storing base_class and primary key
Expand Down
4 changes: 2 additions & 2 deletions app/models/manager_refresh/inventory_collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ def process_db_record!(record)

attributes = record.attributes.symbolize_keys
attribute_references.each do |ref|
# We need to fill all references that are relations, we will use a ManagerRefresh::ApplicationRecordLite which
# We need to fill all references that are relations, we will use a ManagerRefresh::ApplicationRecordReference which
# can be used for filling a relation and we don't need to do any query here
# TODO(lsmola) maybe loading all, not just referenced here? Otherwise this will have issue for db_cache_all
# and find used in parser
next unless (foreign_key = association_to_foreign_key_mapping[ref])
base_class_name = attributes[association_to_foreign_type_mapping[ref].try(:to_sym)] || association_to_base_class_mapping[ref]
id = attributes[foreign_key.to_sym]
attributes[ref] = ManagerRefresh::ApplicationRecordLite.new(base_class_name, id)
attributes[ref] = ManagerRefresh::ApplicationRecordReference.new(base_class_name, id)
end

db_data_index[index] = new_inventory_object(attributes)
Expand Down
2 changes: 1 addition & 1 deletion app/models/manager_refresh/inventory_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def allowed?(inventory_collection_scope, key)

def loadable?(value)
value.kind_of?(::ManagerRefresh::InventoryObjectLazy) || value.kind_of?(::ManagerRefresh::InventoryObject) ||
value.kind_of?(::ManagerRefresh::ApplicationRecordLite)
value.kind_of?(::ManagerRefresh::ApplicationRecordReference)
end
end
end

0 comments on commit 19e7dcc

Please sign in to comment.