synced 0.0.5 → 0.0.6

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: 9b354ac0d6a11182622ca00701ea3e659280017b
4
- data.tar.gz: 106c323663177869a9d0f458edafa4bbb81f2b2c
3
+ metadata.gz: 2075259c1aca0cf57a6228678bde16380e0c48ab
4
+ data.tar.gz: 41355156201bbdb779e221fc68007334171237e8
5
5
  SHA512:
6
- metadata.gz: a583f7a72398c4b0bd0103eea0dbf6124305c24cf0615ab7987409b68c97c202a6bb00cd27a699196d33dc5f53f88cef2cbbdbc8ac7dcdccb06ae3e3a01d1a0f
7
- data.tar.gz: 7ebde8714a3f64bce1fd301fd0f31965fda175e42ff6decf5735661a699f29826266632083516509a799370dfd382671533b9ce10355e365ef9ee846373fdf2f
6
+ metadata.gz: 13247ea4001345d7787945c28b18f5ce9514ea9cdd2689ddb32f9356fe2c65af5bbf5eb72404285aa5b605fac310bafad405281d95f66a0793436778b441446f
7
+ data.tar.gz: aba2f3e3f5a14db5e8bb81aa7c3a654fe5a0990647ffd147428229416423f1a86f2956535970e5721e58c639f059ae47c82441b0473717c2a114da4585414426
@@ -47,6 +47,8 @@ module Synced
47
47
  # if it's missing, all will be destroyed with destroy_all.
48
48
  # You can also force method to remove local objects by passing it
49
49
  # to remove: :mark_as_missing.
50
+ # @param api [BookingSync::API::Client] - API client to be used for fetching
51
+ # remote objects
50
52
  # @example Synchronizing amenities
51
53
  #
52
54
  # Amenity.synchronize(remote: [remote_amenity1, remote_amenity2])
@@ -58,7 +60,7 @@ module Synced
58
60
  # Rental.synchronize(remote: remote_rentals, scope: website)
59
61
  #
60
62
  def synchronize(remote: nil, model_class: self, scope: nil, remove: false,
61
- include: nil)
63
+ include: nil, api: api)
62
64
  options = {
63
65
  scope: scope,
64
66
  id_key: synced_id_key,
@@ -68,7 +70,8 @@ module Synced
68
70
  local_attributes: synced_local_attributes,
69
71
  associations: synced_associations,
70
72
  only_updated: synced_only_updated,
71
- include: include
73
+ include: include,
74
+ api: api
72
75
  }
73
76
  synchronizer = Synced::Synchronizer.new(remote, model_class, options)
74
77
  synchronizer.perform
@@ -30,6 +30,8 @@ module Synced
30
30
  # if it's missing, all will be destroyed with destroy_all.
31
31
  # You can also force method to remove local objects by passing it
32
32
  # to remove: :mark_as_missing.
33
+ # @param api [BookingSync::API::Client] - API client to be used for fetching
34
+ # remote objects
33
35
  # @option options [Boolean] only_updated: If true requests to API will take
34
36
  # advantage of updated_since param and fetch only created/changed/deleted
35
37
  # remote objects
@@ -43,6 +45,7 @@ module Synced
43
45
  @only_updated = options[:only_updated]
44
46
  @include = options[:include]
45
47
  @local_attributes = options[:local_attributes]
48
+ @api = options[:api]
46
49
  @associations = Array(options[:associations])
47
50
  @remote_objects = Array(remote_objects) if remote_objects
48
51
  @request_performed = false
@@ -105,6 +108,7 @@ module Synced
105
108
  # @raise [BookingSync::API::Unauthorized] - On unauthorized user
106
109
  # @return [BookingSync::API::Client] BookingSync API client
107
110
  def api
111
+ return @api if @api
108
112
  closest = [@scope, @scope.class, @model_class].detect do |o|
109
113
  o.respond_to?(:api)
110
114
  end
@@ -1,3 +1,3 @@
1
1
  module Synced
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synced
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Grosjean
8
+ - Mariusz Pietrzyk
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-07-24 00:00:00.000000000 Z
12
+ date: 2014-07-29 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails