README.md in syncify-0.1.0 vs README.md in syncify-0.1.1
- old
+ new
@@ -70,11 +70,11 @@
Running the above example will copy two records into your local database:
* The `Widget` with id 123 (Lubricated Stainless Steel Helical Insert)
* The `Manufacturer` with id 78 (South Seas Trading Company)
-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.
+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.
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:
```ruby
Widget.eager_load(:manufacturer).find(123)
@@ -114,11 +114,11 @@
You can really go wild with the associations; well beyond what you could normally run with an ActiveRecord query! In one app I have a hash defining a ton of associations across dozens of models that is more than 150 lines long. When I run this sync it identifies more than 500 records and syncs them all to local dev in about 30 seconds.
### Polymorphic Associations
-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.
+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.
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.
Here's our model:
@@ -148,29 +148,29 @@
Here's an example. For simplicity's sake it assumes that the database doesn't use foreign keys. (Don't worry, we'll do a more complex example next!):
```ruby
Syncify::Sync.run!(klass: Customer,
id: 999,
- association: Syncer::PolymorphicAssociation.new(
+ association: Syncify::PolymorphicAssociation.new(
:product,
DigitalProduct => {},
PhysicalProduct => {}
),
remote_database: :production)
```
Assuming that line item 42's product is a `DigitalProduct`, this example would have synced the `LineItem` and its `DigitalProduct` and nothing else.
-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).
+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).
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:
```ruby
Syncify::Sync.run!(klass: Customer,
id: 999,
association: {
invoices: {
- line_items: Syncer::PolymorphicAssociation.new(
+ line_items: Syncify::PolymorphicAssociation.new(
:product,
DigitalProduct => :category,
PhysicalProduct => :distributor
)
}