{"id":22394050,"url":"https://github.com/flant/syncable_models","last_synced_at":"2025-03-26T22:40:58.017Z","repository":{"id":59157039,"uuid":"52527453","full_name":"flant/syncable_models","owner":"flant","description":null,"archived":false,"fork":false,"pushed_at":"2016-05-20T10:58:52.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-23T01:02:45.289Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flant.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-25T13:45:52.000Z","updated_at":"2016-02-26T09:05:23.000Z","dependencies_parsed_at":"2022-09-13T17:51:02.950Z","dependency_job_id":null,"html_url":"https://github.com/flant/syncable_models","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flant%2Fsyncable_models","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flant%2Fsyncable_models/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flant%2Fsyncable_models/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flant%2Fsyncable_models/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flant","download_url":"https://codeload.github.com/flant/syncable_models/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245749795,"owners_count":20666084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-05T05:08:45.761Z","updated_at":"2025-03-26T22:40:57.971Z","avatar_url":"https://github.com/flant.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SyncableModels [![Build Status](https://travis-ci.org/flant/syncable_models.svg?branch=master)](https://travis-ci.org/flant/syncable_models) [![Gem Version](https://badge.fury.io/rb/syncable_models.svg)](https://badge.fury.io/rb/syncable_models)\n\nThis gem helps you to:\n\n1. Fetch object attributes from the outside of your app\n2. Mark objects as synced by a special tag\n3. Drop this marks automatically when the object updates\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'syncable_models'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install syncable_models\n\nThen generate and run migration for Sync model:\n\n    $ rails syncable_models:install:migrations\n    $ rake db:migrate\n\n## Usage\n\nAt first you should mark you model as syncable:\n\n```ruby\nclass Project \u003c ApplicationRecord\n  include SyncableModels::ActiveRecord\n  ...\nend\n```\n\nThen create a controller with API methods.\n\n```ruby\nclass ImportApiController \u003c ApplicationController\n  include SyncableModels::Controller\n  sync_for :projects\nend\n```\n\nThis code will automatically generate two api methods for this controller:\n\n1. `projects` - get a list of non-synced Project objects\n  * receives: destination argument - the tag for syncing and an optional count parameter (default value is 50).\n  * returns: response with an array of the objects, non-synced by this tag\n2. `sync_projects` - sync Project objects by a tag\n  * receives: ids - an array of objects' ids for syncing; destination - tag for syncing\n  * returns: {status: 200} if everything is Ok.\n\nExample:\n```\nhttp://host.dev/import_api/projects?destination=redmine\u0026count=50\nhttp://host.dev/import_api/sync_projects?ids[]=c4bebd13-7de4-450d-82d7-e9a575f978c7\u0026destination=redmine\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflant%2Fsyncable_models","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflant%2Fsyncable_models","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflant%2Fsyncable_models/lists"}