Module: Mumukit::Sync

Defined in:
lib/mumukit/sync/syncer.rb,
lib/mumukit/sync.rb,
lib/mumukit/sync/store.rb,
lib/mumukit/sync/version.rb,
lib/mumukit/sync/inflator.rb

Overview

An import and export pipeline for generic resources.

A resource - that is, something that can be imported or exported - must implement the following methods:

  • #sync_key: returns a kind-id pair created using ‘Mumukit::Sync.key`, used to locate resources within a store

  • #to_resource_h: returns a canonical hash representation of the resource. Only required by ‘Mumukit::Sync#export!`

  • #import_from_resource_h!: populates and saves the resource with its canonical hash representation

  • .locate_resource(resource_id): finds or initializes the resource given its resource id. Only required by ‘Mumukit::Sync#import_all!`

Defined Under Namespace

Modules: Inflator, Store Classes: SyncError, Syncer

Constant Summary collapse

VERSION =
'1.0.3'

Class Method Summary collapse

Class Method Details

.classify(kind) ⇒ Object

depracated



26
27
28
# File 'lib/mumukit/sync.rb', line 26

def self.classify(kind)
  kind.as_module_name
end

.constantize(kind) ⇒ Object

depracated



21
22
23
# File 'lib/mumukit/sync.rb', line 21

def self.constantize(kind)
  kind.as_module
end

.key(kind, id) ⇒ Object

Creates a sync key, composed of a ‘kind` and `id`

kind: string|symbol|class id: object

Warning: in order to test the ‘kind`, always use the `like?` message



16
17
18
# File 'lib/mumukit/sync.rb', line 16

def self.key(kind, id)
  struct kind: kind, id: id
end