Sha256: 24b2b76201acdb96e72a234d4aa476333db85d3cd346e50ac12bd88d92d5cb71

Contents?: true

Size: 759 Bytes

Versions: 4

Compression:

Stored size: 759 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.as_variable_name.pluralize)
          .map { |it| Mumukit::Sync.key kind, it['slug']  }
      end
    end

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

    def write_resource!(*)
      Mumukit::Sync::Store.read_only!
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
mumuki-domain-7.0.1 lib/mumuki/domain/stores/bibliotheca_store.rb
mumuki-domain-7.0.0 lib/mumuki/domain/stores/bibliotheca_store.rb
mumukit-sync-0.4.1 lib/mumukit/sync/store/bibliotheca.rb
mumukit-sync-0.4.0 lib/mumukit/sync/store/bibliotheca.rb