Sha256: 8dc060c627858d82feae9dc9dd4feb056f68ac2b9a161975e182662ffc7ad4d7

Contents?: true

Size: 722 Bytes

Versions: 1

Compression:

Stored size: 722 Bytes

Contents

module Mumukit::Sync::Store

  ## This Store enables importing content
  ## from Bibliotheca API
  class Bibliotheca < Mumukit::Sync::Store::Base
    include Mumukit::Sync::Store::WithWrappedLanguage
    include Mumukit::Sync::Store::WithFilteredId

    def initialize(bibliotheca_bridge)
      @bibliotheca_bridge = bibliotheca_bridge
    end

    def sync_keys
      %w(guide topic book).flat_map do |kind|
        @bibliotheca_bridge
          .send(kind.to_s.pluralize)
          .map { |it| Mumukit::Sync.key kind, it['slug']  }
      end
    end

    def do_read(sync_key)
      @bibliotheca_bridge.send(sync_key.kind, sync_key.id)
    end

    def write_resource!(*)
      raise 'Read-only store'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mumukit-sync-0.3.0 lib/mumukit/sync/store/bibliotheca.rb