Module: SyncMachine

Defined in:
lib/sync_machine.rb,
lib/sync_machine/railtie.rb,
lib/sync_machine/version.rb,
lib/sync_machine/redis_lock.rb,
lib/sync_machine/orm_adapters.rb,
lib/sync_machine/change_listener.rb,
lib/sync_machine/tracer_adapters.rb,
lib/sync_machine/ensure_publication.rb,
lib/sync_machine/find_subjects_worker.rb,
lib/sync_machine/ensure_publication_worker.rb,
lib/sync_machine/ensure_publication/deduper.rb,
lib/sync_machine/orm_adapters/mongoid_adapter.rb,
lib/sync_machine/orm_adapters/active_record_adapter.rb,
lib/sync_machine/tracer_adapters/open_tracing_adapter.rb,
lib/sync_machine/ensure_publication/publication_history.rb

Overview

A mini-framework for intelligently publishing complex model changes to an external API..

Defined Under Namespace

Modules: OrmAdapters, TracerAdapters Classes: ChangeListener, EnsurePublication, EnsurePublicationWorker, FindSubjectsWorker, Railtie, RedisLock

Constant Summary collapse

VERSION =
"1.4.0".freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.abort_with_installation_hint(gem_name, dependency) ⇒ Object



17
18
19
20
21
# File 'lib/sync_machine.rb', line 17

def self.abort_with_installation_hint(gem_name, dependency)
  Kernel.abort(
    "Please install the #{gem_name} gem when using SyncMachine with #{dependency}."
  )
end

.eager_load(base) ⇒ Object

Force loading of all relevant classes. Should only be necessary when running your application in a way that it defers loading constants, i.e., Rails’ development or test mode.



26
27
28
29
30
31
32
33
# File 'lib/sync_machine.rb', line 26

def self.eager_load(base)
  const_names = %w(
    Payload FindSubjectsWorker EnsurePublicationWorker ChangeListener
  )
  const_names.each do |const_name|
    base.const_get(const_name)
  end
end

.extended(base) ⇒ Object



35
36
37
38
# File 'lib/sync_machine.rb', line 35

def self.extended(base)
  base.mattr_accessor :subject_sym
  base.mattr_accessor :subject_opts
end

.sync_module(child_const) ⇒ Object



40
41
42
# File 'lib/sync_machine.rb', line 40

def self.sync_module(child_const)
  child_const.name.split(/::/)[0..-2].join('::').constantize
end

Instance Method Details

#orm_adapterObject



44
45
46
# File 'lib/sync_machine.rb', line 44

def orm_adapter
  SyncMachine::OrmAdapters.orm_adapter(self)
end

#subject(subject_sym, opts = {}) ⇒ Object



48
49
50
51
# File 'lib/sync_machine.rb', line 48

def subject(subject_sym, opts = {})
  self.subject_sym = subject_sym
  self.subject_opts = ActiveSupport::HashWithIndifferentAccess.new(opts)
end

#subject_classObject



53
54
55
# File 'lib/sync_machine.rb', line 53

def subject_class
  (subject_opts[:class_name] || subject_sym.to_s.camelize).constantize
end