Sha256: 264b55c580a184995f3d459942c6cbc5a5c95a81d15d54c71cbee1449ae8750c

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require "active_support/core_ext/class"
require "active_support/core_ext/string"
require "sync_machine/change_listener"
require "sync_machine/ensure_publication"
require "sync_machine/ensure_publication/deduper"
require "sync_machine/ensure_publication/publication_history"
require "sync_machine/ensure_publication_worker"
require "sync_machine/find_subjects_worker"
require "sync_machine/version"

# A mini-framework for intelligently publishing complex model changes to an
# external API..
module SyncMachine
  # 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.
  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

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

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

  def subject(subject_sym)
    self.subject_sym = subject_sym
  end

  def subject_class
    subject_sym.to_s.camelize.constantize
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sync_machine-0.4.0 lib/sync_machine.rb