Class: Restforce::DB::Strategies::Associated

Inherits:
Object
  • Object
show all
Defined in:
lib/restforce/db/strategies/associated.rb

Overview

Restforce::DB::Strategies::Associated defines an initialization strategy for a mapping in which newly-discovered records should only be synchronized into the other system when a specific associated record has already been synchronized.

Instance Method Summary collapse

Constructor Details

#initialize(with:) ⇒ Associated

Public: Initialize a Restforce::DB::Strategies::Associated for the passed mapping.

with - A Symbol name of the association which should be checked.



17
18
19
# File 'lib/restforce/db/strategies/associated.rb', line 17

def initialize(with:)
  @association = with.to_sym
end

Instance Method Details

#build?(record) ⇒ Boolean

Public: Should the passed record be constructed in the other system?

record - A Restforce::DB::Instances::Base.

Returns a Boolean.

Returns:

  • (Boolean)


26
27
28
# File 'lib/restforce/db/strategies/associated.rb', line 26

def build?(record)
  !record.synced? && target_association(record.mapping).synced_for?(record)
end

#passive?Boolean

Public: Is this a passive sync strategy?

Returns false.

Returns:

  • (Boolean)


33
34
35
# File 'lib/restforce/db/strategies/associated.rb', line 33

def passive?
  false
end