Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/syncromesh.rb,
lib/syncromesh.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.no_auto_syncObject



6
7
8
# File 'lib/syncromesh.rb', line 6

def no_auto_sync
  @no_auto_sync = true
end

.old_scopeObject



10
# File 'lib/syncromesh.rb', line 10

alias_method :old_scope, :scope

.scope(name, server, client = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/syncromesh.rb', line 12

def scope(name, server, client = nil)
  if server == :no_sync
    server = client
    client = nil
  elsif client.nil? && @no_auto_sync.nil?
    client = server
  end
  if RUBY_ENGINE == 'opal' && client
    to_sync name do |scope, model|
      if ReactiveRecord::SyncWrapper.new(model).instance_eval(&client)
        scope << model
      else
        scope.delete(model)
      end
    end
  end
  old_scope(name, server)
end

Instance Method Details

#syncromesh_after_changeObject



148
149
150
# File 'lib/syncromesh.rb', line 148

def syncromesh_after_change
  Syncromesh.after_change self
end

#syncromesh_after_destroyObject



152
153
154
# File 'lib/syncromesh.rb', line 152

def syncromesh_after_destroy
  Syncromesh.after_destroy self
end