0.0
No commit activity in last 3 years
No release in over 3 years
The gem provides tagged syncing functionality and API methods.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 4.2.5
>= 0.9.2
>= 4.2.5
 Project Readme

SyncableModels Build Status Gem Version

This gem helps you to:

  1. Fetch object attributes from the outside of your app
  2. Mark objects as synced by a special tag
  3. Drop this marks automatically when the object updates

Installation

Add this line to your application's Gemfile:

gem 'syncable_models'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install syncable_models

Then generate and run migration for Sync model:

$ rails syncable_models:install:migrations
$ rake db:migrate

Usage

At first you should mark you model as syncable:

class Project < ApplicationRecord
  include SyncableModels::ActiveRecord
  ...
end

Then create a controller with API methods.

class ImportApiController < ApplicationController
  include SyncableModels::Controller
  sync_for :projects
end

This code will automatically generate two api methods for this controller:

  1. projects - get a list of non-synced Project objects
  • receives: destination argument - the tag for syncing and an optional count parameter (default value is 50).
  • returns: response with an array of the objects, non-synced by this tag
  1. sync_projects - sync Project objects by a tag
  • receives: ids - an array of objects' ids for syncing; destination - tag for syncing
  • returns: {status: 200} if everything is Ok.

Example:

http://host.dev/import_api/projects?destination=redmine&count=50
http://host.dev/import_api/sync_projects?ids[]=c4bebd13-7de4-450d-82d7-e9a575f978c7&destination=redmine