syncify 0.1.0 → 0.1.1

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: cb790579afcec3a69a0241d30029691ede3a17ef
4
- data.tar.gz: 71380e359bb049e5f945337e4948c2d3a6bab75e
3
+ metadata.gz: 732f3fd3c050a56656ad4eb272412d59528dd0ef
4
+ data.tar.gz: 6e400731043ff844d4edb694ec68f7c354a68909
5
5
  SHA512:
6
- metadata.gz: d019996265b60d5a5f9c3a721e27282815766a2a3a7de3b514cccd21599d2e68b8319d6a78b78f3a31ee4a14701ea65b9db7bdc95ec8431c8a7f13ecd7e6dbdd
7
- data.tar.gz: d8e4eaca79bae5ba9058f1205e46b8d88db5f1211262b55c35d106814f729cf69871e9856445d04f2e7b1ee22bebca94de3132851261ad35dfdf51d2ddff1616
6
+ metadata.gz: d5c78f9f3b5306c79acbd67a37809166d6f296eb79dbff0183c7a6ecdeca3f0106602e1b003ebf67591208b476d727f2ccac40ae98f414568a5ccde73ba212cb
7
+ data.tar.gz: 1c54d9823b93cb12d74d4b249222182f2b090c87c7cb83044b816aed3adc6c86fcaaf94f0d9601026f581e9a4a4b276e36928da1babaef7f52049d381824fd6d
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.gem
1
2
  /.bundle/
2
3
  /.yardoc
3
4
  /_yardoc/
data/README.md CHANGED
@@ -72,7 +72,7 @@ Running the above example will copy two records into your local database:
72
72
  * The `Widget` with id 123 (Lubricated Stainless Steel Helical Insert)
73
73
  * The `Manufacturer` with id 78 (South Seas Trading Company)
74
74
 
75
- It's important to note that Syncer _does not_ recursively follow associations. You'll note that not all of the the manufacturer's widgets were synced, only the one we specified.
75
+ It's important to note that Syncify _does not_ recursively follow associations. You'll note that not all of the the manufacturer's widgets were synced, only the one we specified.
76
76
 
77
77
  The `association` attribute passed into the `run!` method can be any valid value that you might use when joining records with ActiveRecord. The above effectively becomes:
78
78
 
@@ -116,7 +116,7 @@ You can really go wild with the associations; well beyond what you could normall
116
116
 
117
117
  ### Polymorphic Associations
118
118
 
119
- Syncify also works with (and across) Polymorphic associations! To sync across polymorphic associations you need to specify an association using the `Syncer::PolymorphicAssociation` class. This is put in place in your otherwise-normal associations.
119
+ Syncify also works with (and across) Polymorphic associations! To sync across polymorphic associations you need to specify an association using the `Syncify::PolymorphicAssociation` class. This is put in place in your otherwise-normal associations.
120
120
 
121
121
  Let's imagine that we run an online store that sells both physical and digital goods. A given invoice then might have line items that refer to either type of good.
122
122
 
@@ -150,7 +150,7 @@ Here's an example. For simplicity's sake it assumes that the database doesn't us
150
150
  ```ruby
151
151
  Syncify::Sync.run!(klass: Customer,
152
152
  id: 999,
153
- association: Syncer::PolymorphicAssociation.new(
153
+ association: Syncify::PolymorphicAssociation.new(
154
154
  :product,
155
155
  DigitalProduct => {},
156
156
  PhysicalProduct => {}
@@ -160,7 +160,7 @@ Syncify::Sync.run!(klass: Customer,
160
160
 
161
161
  Assuming that line item 42's product is a `DigitalProduct`, this example would have synced the `LineItem` and its `DigitalProduct` and nothing else.
162
162
 
163
- The `Syncer::PolymorphicAssociation` is saying that, for the `LineItem`'s `product` polymorphic association, when the product is a `DigitalProduct`, sync it with the specified associations (in this case none). When the product is a `PhysicalProduct`, sync it with the specified associations (again, none in this case).
163
+ The `Syncify::PolymorphicAssociation` is saying that, for the `LineItem`'s `product` polymorphic association, when the product is a `DigitalProduct`, sync it with the specified associations (in this case none). When the product is a `PhysicalProduct`, sync it with the specified associations (again, none in this case).
164
164
 
165
165
  Now let's say that we want to sync a specific `Customer` and all of their invoices and the related products. IE: the whole kit and caboodle. Here's how you can do it:
166
166
 
@@ -169,7 +169,7 @@ Syncify::Sync.run!(klass: Customer,
169
169
  id: 999,
170
170
  association: {
171
171
  invoices: {
172
- line_items: Syncer::PolymorphicAssociation.new(
172
+ line_items: Syncify::PolymorphicAssociation.new(
173
173
  :product,
174
174
  DigitalProduct => :category,
175
175
  PhysicalProduct => :distributor
data/lib/syncify/sync.rb CHANGED
@@ -49,6 +49,7 @@ module Syncify
49
49
  end
50
50
  else
51
51
  target = root.__send__(polymorphic_association.property)
52
+ next if target.nil?
52
53
  type = polymorphic_association.associations.keys.detect do |association_type|
53
54
  target.is_a?(association_type)
54
55
  end
@@ -1,3 +1,3 @@
1
1
  module Syncify
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syncify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Hughes