module Replication::Process

Public Instance Methods

can_replicate(pairs_method = :attributes, **options) click to toggle source
# File lib/replication/process.rb, line 4
def can_replicate(pairs_method = :attributes, **options)
  reset_config if self.respond_to?(:unwound)

  default_options = Replication.defaults
  modules = [:semi_conservative] # required module
  modules.concat([].push(options.delete(:with)).flatten).compact!

  replication_config.pairs_method = pairs_method
  replication_config.set default_options.merge(options)
  replication_config.with modules

  include Model
end
new_from_strand(id=nil, **options) click to toggle source
# File lib/replication/process.rb, line 18
def new_from_strand(id=nil, **options)
  if id
    strand = replication_config.strand_class.to_adapter.get!(id)
  else
    strand = replication_config.strand_class.to_adapter.find_first(options)
  end

  new(strand.pairs) if strand
end
replication_config() click to toggle source
# File lib/replication/process.rb, line 32
def replication_config
  @replication_config ||= base_class.replication_config.dup.tap do |config|
    config.model_class = self
  end
end
reset_config() click to toggle source
# File lib/replication/process.rb, line 28
def reset_config
  @replication_config = nil
end