app/operations/harvesting/entities/upsert.rb
def scope_for(parent, harvest_entity)
        parent_type = yield type_for parent

        child_type = yield type_for harvest_entity

        case [parent_type, child_type]
        when [:collection, :item]
          Success parent.items
        when [:collection, :collection], [:item, :item]
          Success parent.children
        else
          # :nocov:
          Failure[:invalid_parentage, "cannot create child of type #{child_type} under #{parent_type}"]
          # :nocov:
        end
      end
# Based on the provided parent and harvest_entity, return the correct scope
# to be consumed by {#find_or_initialize_entity_for}.
#
# @return [Dry::Monads::Success(ActiveRecord::Relation)]
# @return [Dry::Monads::Failure]
Based on the provided parent and harvest_entity, return the correct scope
to be consumed by {#find_or_initialize_entity_for}.
Based on the provided parent and harvest_entity return the correct scope to be consumed by { #find_or_initialize_entity_for } .
def scope_for(parent, harvest_entity)
        parent_type = yield type_for parent
        child_type = yield type_for harvest_entity
        case [parent_type, child_type]
        when [:collection, :item]
          Success parent.items
        when [:collection, :collection], [:item, :item]
          Success parent.children
        else
          Failure[:invalid_parentage, "cannot create child of type #{child_type} under #{parent_type}"]
        end
      end
def scope_for ( parent , harvest_entity ) parent_type = yield type_for parent child_type = yield type_for harvest_entity case [ parent_type , child_type ] when [ :collection , :item ] Success parent . items when [ :collection , :collection ] , [ :item , :item ] Success parent . children else Failure [ :invalid_parentage , "cannot create child of type #{child_type} under #{parent_type}" ] end end
Based on the provided parent and harvest_entity, return the correct scope
to be consumed by {#find_or_initialize_entity_for}.
Based on the provided parent and harvest_entity return the correct scope to be consumed by { #find_or_initialize_entity_for } .
# :nocov: # :nocov:
None
Dry::Monads::Success(ActiveRecord::Relation)
None
Dry::Monads::Failure
parent
harvest_entity