Class: CaRuby::Database::FetchedMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/caruby/database/fetched_matcher.rb

Overview

Helper that matches fetched sources to targets.

Direct Known Subclasses

SavedMatcher

Instance Method Summary collapse

Instance Method Details

#match(sources, targets, from, attribute) ⇒ {Jinx::Resource => Jinx::Resource}

Returns a target => source match hash for the given targets and sources using Jinx::Resource#match_in_owner_scope.

caCORE alert = caCORE does not enforce reference identity integrity, i.e. a search on object a with database record references a => b => a, the search result might be a => b => a’, where a.identifier == _a’.identifier_. This visit method remedies this caCORE defect by matching source references on a previously matched identifier where possible.

Parameters:

  • sources (<Jinx::Resource>)

    the domain objects to match against

  • targets (<Jinx::Resource>)

    the domain objects to match

  • from (Resource)

    the visiting domain object

  • attribute (Symbol)

    the visiting attribute

Returns:

  • ({Jinx::Resource => Jinx::Resource})

    the source => target matches



21
22
23
24
25
26
27
28
29
# File 'lib/caruby/database/fetched_matcher.rb', line 21

def match(sources, targets, from, attribute)
  if sources.empty? or targets.empty? then
    Hash::EMPTY_HASH 
  elsif from.class.property(attribute).owner? then
    match_owner(sources.first, targets.first, from, attribute)
  else
    match_fetched(sources, targets)
  end
end