Module: Synchronisable

Defined in:
lib/synchronisable.rb,
lib/synchronisable/model.rb,
lib/synchronisable/source.rb,
lib/synchronisable/gateway.rb,
lib/synchronisable/context.rb,
lib/synchronisable/version.rb,
lib/synchronisable/dsl/macro.rb,
lib/synchronisable/controller.rb,
lib/synchronisable/exceptions.rb,
lib/synchronisable/worker/base.rb,
lib/synchronisable/model/scopes.rb,
lib/synchronisable/input/parser.rb,
lib/synchronisable/synchronizer.rb,
lib/synchronisable/models/import.rb,
lib/synchronisable/model/methods.rb,
lib/synchronisable/configuration.rb,
lib/synchronisable/worker/record.rb,
lib/synchronisable/error_handler.rb,
lib/synchronisable/helper/logging.rb,
lib/synchronisable/dsl/association.rb,
lib/synchronisable/attribute_mapper.rb,
lib/synchronisable/dsl/macro/method.rb,
lib/synchronisable/input/descriptor.rb,
lib/synchronisable/dsl/associations.rb,
lib/synchronisable/dsl/macro/attribute.rb,
lib/synchronisable/worker/associations.rb,
lib/synchronisable/dsl/macro/expression.rb,
lib/generators/synchronisable/install_generator.rb,
lib/synchronisable/synchronizers/synchronizer_default.rb

Defined Under Namespace

Modules: DSL, Helper, Input, Model, VERSION, Worker Classes: AttributeMapper, Configuration, Context, Controller, ErrorHandler, Gateway, Import, InstallGenerator, MissedAssociationsError, MissedRemoteIdError, Source, Synchronizer, SynchronizerDefault

Class Method Summary collapse

Class Method Details

.configObject


26
27
28
# File 'lib/synchronisable.rb', line 26

def self.config
  @configuration ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:


30
31
32
# File 'lib/synchronisable.rb', line 30

def self.configure
  yield config
end

.sync(models, options) ⇒ Array<[Synchronisable::Context]> .sync(models) ⇒ Array<[Synchronisable::Context]>

Syncs models that are defined in #models

Overloads:

  • .sync(models, options) ⇒ Array<[Synchronisable::Context]>

    Parameters:

    • models (Array)

      array of models that should be synchronized. This take a precedence over models defined in #models. If this parameter is not specified and #models is empty, than it will try to sync only those models which have a corresponding synchronizers

    • options (Hash)

      options that will be passed to controller

Returns:

See Also:


57
58
59
60
61
# File 'lib/synchronisable.rb', line 57

def self.sync(*args)
  options = args.extract_options!
  source = source_models(args) 
  source.map { |model| model.sync(options) }
end

.using(logger: config.logger, models: config.models) ⇒ Object

Calls the given block using temporary configuration


35
36
37
38
39
40
41
# File 'lib/synchronisable.rb', line 35

def self.using(logger: config.logger, models: config.models)
  snapshot = config.clone
  config.logger = logger
  config.models = models
  yield
  @configuration = snapshot
end