Module: Synchronisable::Model::ClassMethods

Defined in:
lib/synchronisable/model.rb

Constant Summary collapse

SYNCHRONIZER_SUFFIX =
'Synchronizer'

Instance Method Summary collapse

Instance Method Details

#synchronisable(klass, options) ⇒ Object #synchronisable(options) ⇒ Object #synchronisableObject

Declare this on your model class to make it synchronisable. After that you can call Methods#sync to start model synchronization.

Examples:

Common usage

class FooModel < ActiveRecord::Base
  synchronisable BarSynchronizer
end

Overloads:

  • #synchronisable(klass, options) ⇒ Object

    Parameters:

    • klass (Class)

      synchronizer class to be used

    • options (Hash)

      describes behavior of synchronisable model

    Options Hash (options):

    • :synchronizer (Class)

      class that provides synchronization configuration

See Also:


31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/synchronisable/model.rb', line 31

def synchronisable(*args)
  extend Synchronisable::Model::Methods
  extend Synchronisable::Model::Scopes

  class_attribute :synchronizer

  options = args.extract_options!

  set_defaults(options)
  set_synchronizer(args, options)

  has_one :import,
    as: :synchronisable,
    class_name: 'Synchronisable::Import',
    dependent: options[:dependent]
end

#synchronisable?Boolean

Returns:

  • (Boolean)

48
49
50
# File 'lib/synchronisable/model.rb', line 48

def synchronisable?
  false
end