Sha256: c94ea0cf854709020f203119e726a0570ef8c10baf8a85b3c96fd03045f3b42b
Contents?: true
Size: 1.97 KB
Versions: 9
Compression:
Stored size: 1.97 KB
Contents
require 'active_record' require 'active_support/core_ext/hash' require 'active_support/core_ext/class/attribute' require 'active_support/core_ext/object/try' require 'active_support/core_ext/object/deep_dup' require 'active_support/core_ext/string/inflections' require 'active_support/configurable' require 'active_support/concern' require 'synchronisable/bootstrap/i18n' require 'synchronisable/version' require 'synchronisable/configuration' require 'synchronisable/models/import' require 'synchronisable/synchronizer' require 'synchronisable/model' require 'synchronisable/gateway' module Synchronisable def self.config @configuration ||= Configuration.new end def self.configure yield config end # Syncs models that are defined in {Synchronisable#models} # # @overload sync(models, options) # @param models [Array] array of models that should be synchronized. # This take a precedence over models defined in {Synchronisable#models}. # If this parameter is not specified and {Synchronisable#models} is empty, # than it will try to sync only those models which have a corresponding synchronizers # @param options [Hash] options that will be passed to controller # @overload sync(models) # @overlaod sync(options) # # @return [Array<[Synchronisable::Context]>] array of synchronization contexts # # @see Synchronisable::Context def self.sync(*args) options = args.extract_options! source = source_models(args) source.map { |model| model.sync(options) } end private def self.source_models(models) source = models.present? ? models : default_models source = source.present? ? source : find_models end def self.default_models config.models.map(&:safe_constantize).compact end def self.find_models ActiveRecord::Base.descendants.select do |model| model.included_modules.include?(Synchronisable::Model) end end end ActiveSupport.on_load(:active_record) do include Synchronisable::Model end
Version data entries
9 entries across 9 versions & 1 rubygems