lib/table_sync.rb in table_sync-0.0.0 vs lib/table_sync.rb in table_sync-1.4.0
- old
+ new
@@ -1,5 +1,55 @@
# frozen_string_literal: true
+require "memery"
+require "rabbit_messaging"
+require "rabbit/event_handler" # NOTE: from rabbit_messaging"
+require "active_support/core_ext/object/blank"
+require "active_support/core_ext/numeric/time"
+
module TableSync
- require "table_sync/version"
+ require_relative "./table_sync/version"
+ require_relative "./table_sync/errors"
+ require_relative "./table_sync/event_actions"
+ require_relative "./table_sync/config"
+ require_relative "./table_sync/config/callback_registry"
+ require_relative "./table_sync/config_decorator"
+ require_relative "./table_sync/dsl"
+ require_relative "./table_sync/receiving_handler"
+ require_relative "./table_sync/base_publisher"
+ require_relative "./table_sync/publisher"
+ require_relative "./table_sync/batch_publisher"
+ require_relative "./table_sync/orm_adapter/active_record"
+ require_relative "./table_sync/orm_adapter/sequel"
+ require_relative "./table_sync/model/active_record"
+ require_relative "./table_sync/model/sequel"
+
+ class << self
+ include Memery
+
+ attr_accessor :publishing_job_class_callable
+ attr_accessor :batch_publishing_job_class_callable
+ attr_accessor :routing_key_callable
+ attr_accessor :exchange_name
+ attr_accessor :routing_metadata_callable
+
+ def sync(*args)
+ orm.setup_sync(*args)
+ end
+
+ def orm=(val)
+ clear_memery_cache!
+ @orm = val
+ end
+
+ memoize def orm
+ case @orm
+ when :active_record
+ ORMAdapter::ActiveRecord
+ when :sequel
+ ORMAdapter::Sequel
+ else
+ raise "ORM not supported: #{@orm.inspect}"
+ end
+ end
+ end
end