synchronisable 1.1.6 → 1.1.7
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02c09a1ef8d6a3cfb421f127643ad5b79655756f
|
4
|
+
data.tar.gz: 7f5e474b07df81f291239fbd71a7a700007cfbaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 453ce50073eb8f24ee073738c08f2a96d2692a0e5ce193e5652fc1800887f61347172ca1ccb83f17f4b0ad7c941b84d9746e519e7ba83db6910c8d9c61d9d648
|
7
|
+
data.tar.gz: a13eff1a136a0b5d001c6a9268dd53e66aeab994ccebb3960f99ca7ac761f72d9d4b439ed0805880d3742fa0924c6f188381b2ff8838129918b443d49f7bdb4d
|
data/README.md
CHANGED
@@ -15,4 +15,8 @@ Synchronisable.configure do |config|
|
|
15
15
|
# a `synchronisable` dsl instruction.
|
16
16
|
#
|
17
17
|
# config.models = %w(Foo Bar)
|
18
|
+
|
19
|
+
# What to do with an associated import record
|
20
|
+
# when its synchronisable is destroyed. Default is `:destroy`.
|
21
|
+
# config.dependent_import = :destroy
|
18
22
|
end
|
@@ -2,9 +2,14 @@ module Synchronisable
|
|
2
2
|
class Configuration
|
3
3
|
include ActiveSupport::Configurable
|
4
4
|
|
5
|
+
config_accessor :dependent_import do
|
6
|
+
:destroy
|
7
|
+
end
|
8
|
+
|
5
9
|
config_accessor :models do
|
6
|
-
|
10
|
+
[]
|
7
11
|
end
|
12
|
+
|
8
13
|
config_accessor :logging do
|
9
14
|
default_logger = -> { Logger.new(STDOUT) }
|
10
15
|
rails_logger = -> { Rails.logger || default_logger.() }
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'synchronisable/models/import'
|
2
|
+
|
3
|
+
module Synchronisable
|
4
|
+
module Model
|
5
|
+
module Scopes
|
6
|
+
def not_imported
|
7
|
+
includes(:import)
|
8
|
+
.where(imports: { synchronisable_id: nil })
|
9
|
+
.references(:imports)
|
10
|
+
end
|
11
|
+
|
12
|
+
def imported
|
13
|
+
includes(:import)
|
14
|
+
.where.not(imports: { synchronisable_id: nil })
|
15
|
+
.refences(:imports)
|
16
|
+
end
|
17
|
+
|
18
|
+
alias_method :without_import, :not_imported
|
19
|
+
alias_method :with_import, :imported
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/synchronisable/model.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'synchronisable/model/methods'
|
2
|
+
require 'synchronisable/model/scopes'
|
2
3
|
require 'synchronisable/synchronizers/synchronizer_default'
|
3
4
|
|
4
5
|
module Synchronisable
|
@@ -29,24 +30,28 @@ module Synchronisable
|
|
29
30
|
# end
|
30
31
|
def synchronisable(*args)
|
31
32
|
extend Synchronisable::Model::Methods
|
33
|
+
extend Synchronisable::Model::Scopes
|
32
34
|
|
33
35
|
class_attribute :synchronizer
|
34
|
-
has_one :import, as: :synchronisable, class_name: 'Synchronisable::Import'
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
}
|
37
|
+
options = args.extract_options!
|
38
|
+
|
39
|
+
set_defaults(options)
|
40
|
+
set_synchronizer(args, options)
|
41
41
|
|
42
|
-
|
42
|
+
has_one :import,
|
43
|
+
as: :synchronisable,
|
44
|
+
class_name: 'Synchronisable::Import',
|
45
|
+
dependent: options[:dependent]
|
43
46
|
end
|
44
47
|
|
45
48
|
private
|
46
49
|
|
47
|
-
def set_defaults(
|
48
|
-
options
|
50
|
+
def set_defaults(options)
|
51
|
+
options[:dependent] ||= Synchronisable.config.dependent_import
|
52
|
+
end
|
49
53
|
|
54
|
+
def set_synchronizer(args, options)
|
50
55
|
self.synchronizer = args.first || options[:synchronizer] ||
|
51
56
|
find_synchronizer || SynchronizerDefault
|
52
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synchronisable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasiliy Yorkin
|
@@ -310,6 +310,7 @@ files:
|
|
310
310
|
- lib/synchronisable/locale/ru.yml
|
311
311
|
- lib/synchronisable/model.rb
|
312
312
|
- lib/synchronisable/model/methods.rb
|
313
|
+
- lib/synchronisable/model/scopes.rb
|
313
314
|
- lib/synchronisable/models/import.rb
|
314
315
|
- lib/synchronisable/source.rb
|
315
316
|
- lib/synchronisable/synchronizer.rb
|