module StoreModel::ParentAssignment

Helper methods for ActiveModel and ActiveRecord parent tracking support

Private Instance Methods

assign_parent_to_singular_store_model(item) click to toggle source
# File lib/store_model/ext/parent_assignment.rb, line 15
def assign_parent_to_singular_store_model(item)
  item.parent = self if item.is_a?(StoreModel::Model)
end
assign_parent_to_store_model_relation(attribute) click to toggle source
# File lib/store_model/ext/parent_assignment.rb, line 8
def assign_parent_to_store_model_relation(attribute)
  assign_parent_to_singular_store_model(attribute)
  return unless attribute.is_a?(Array)

  attribute.each(&method(:assign_parent_to_singular_store_model))
end