Sha256: 5aa6b2254a2e01f148f70cf74081fa0d0e451cb0f75c75f468edf1ac48e2908b

Contents?: true

Size: 527 Bytes

Versions: 37

Compression:

Stored size: 527 Bytes

Contents

# frozen_string_literal: true

module StoreModel
  # Helper methods for ActiveModel and ActiveRecord parent tracking support
  module ParentAssignment
    private

    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

    def assign_parent_to_singular_store_model(item)
      item.parent = self if item.is_a?(StoreModel::Model)
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
store_model-4.2.0 lib/store_model/ext/parent_assignment.rb
store_model-4.1.0 lib/store_model/ext/parent_assignment.rb
store_model-4.0.0 lib/store_model/ext/parent_assignment.rb
store_model-3.0.2 lib/store_model/ext/parent_assignment.rb
store_model-3.0.1 lib/store_model/ext/parent_assignment.rb
store_model-3.0.0 lib/store_model/ext/parent_assignment.rb
store_model-2.4.0 lib/store_model/ext/parent_assignment.rb
store_model-2.3.0 lib/store_model/ext/parent_assignment.rb
store_model-2.2.0 lib/store_model/ext/parent_assignment.rb
store_model-2.1.2 lib/store_model/ext/parent_assignment.rb
store_model-2.1.1 lib/store_model/ext/parent_assignment.rb
store_model-2.1.0 lib/store_model/ext/parent_assignment.rb
store_model-2.0.1 lib/store_model/ext/parent_assignment.rb
store_model-2.0.0 lib/store_model/ext/parent_assignment.rb
store_model-1.6.2 lib/store_model/ext/parent_assignment.rb
store_model-1.6.1 lib/store_model/ext/parent_assignment.rb
store_model-1.6.0 lib/store_model/ext/parent_assignment.rb
store_model-1.5.1 lib/store_model/ext/parent_assignment.rb
store_model-1.5.0 lib/store_model/ext/parent_assignment.rb
store_model-1.4.0 lib/store_model/ext/parent_assignment.rb